Skip to content


Deleted posts don't decrement progress counts for "on post published" event #67

paulgibbs opened this Issue · 2 comments

2 participants


Support for this would involve special-casing this event. Before doing so, think about if any other achievements have a similar problem, and see if there's a unified way of dealing with them all.


Here's how I did it, but it breaks in certain circumstances:

    add_filter( 'dpa_maybe_unlock_achievement_progress_increment', array( $this, 'maybe_decrement'));
    add_action( 'sennza_likes', array( $this, 'run_sennza_likes' ), 10 );
    add_action( 'sennza_likes_unlike', array( $this, 'run_sennza_likes' ), 10 );

    public function run_sennza_likes($post_id) {
        $user = get_current_user_id();
        if ( empty( $user ) )

        if (current_filter() === 'sennza_likes_unlike')
            $this->decrement = true;

        do_action( 'ts_sennza_likes' );

    public function maybe_decrement($step) {
        if ( $this->decrement === true ) {
            $step = -1;
            $this->decrement = false;
        return $step;

Specifically, it breaks when using recurring achievements with no limit/repeat, as the same action is used for both.

In a prospective general solution, it would use the same progress object for both actions and use the same step filter, but I didn't have time for implementing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.