Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Achievements Plugin Not Working


kharla
Participant

@kharla

Okay, I’ve been able to correct most of the problems like the avatar achievement, blog creation achievement, account activation achievement, etc by correcting the code in the dp-achievements-defaultachievements.php file.

However, there are two sets of achievements that are still not working.

Starting A Forum Topic (one, thirty, and 100) – this hooks into action – bp_forums_new_topic

function dpa_register_forumranked() { add_action( ‘bp_forums_new_topic’, ‘dpa_handle_forumranked’, 10, 0 ); }

Replying To A Forum Topic (one, thirty, and 100) – this hooks into action – bp_forums_new_post

function dpa_register_replyranked() { add_action( ‘bp_forums_new_post’, ‘dpa_handle_replyranked’, 10, 0 ); }

I’ve been checking all of the code both in this file and in the bp-forums.php file and cannot see why it’s not working. The actions are correct, I can’t find any typos, why is it not unlocking the achievements?

function dpa_handle_forumranked() {

global $bp;

if ( !function_exists( ‘bp_forums_is_installed_correctly’ ) || !bp_forums_is_installed_correctly() || defined( ‘DPA_CHECKING’ ) )

return;

$user_id = $bp->loggedin_user->id;

$one = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘forumranked_1’, ‘counter’ => true ) );

$thirty = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘forumranked_30’ ) );

$hundred = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘forumranked_100’ ) );

if ( $hundred->is_unlocked() )

return;

$one->increment_counter();

if ( $one->counter >= 1 && !$one->is_unlocked() ) { $one->unlock_achievement(); }

if ( $one->counter >= 30 && !$thirty->is_unlocked() ) { $thirty->unlock_achievement(); }

if ( $one->counter >= 100 && !$hundred->is_unlocked() ) { $hundred->unlock_achievement(); }

}

function dpa_handle_replyranked() {

global $bp;

if ( !function_exists( ‘bp_forums_is_installed_correctly’ ) || !bp_forums_is_installed_correctly() || defined( ‘DPA_CHECKING’ ) )

return;

$user_id = $bp->loggedin_user->id;

$one = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘replyranked_1’, ‘counter’ => true ) );

$thirty = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘replyranked_30’ ) );

$hundred = new dpa_achievement( array( ‘user_id’ => $user_id, ‘name’ => ‘replyranked_100’ ) );

if ( $hundred->is_unlocked() )

return;

$one->increment_counter();

if ( $one->counter >= 1 && !$one->is_unlocked() ) { $one->unlock_achievement(); }

if ( $one->counter >= 30 && !$thirty->is_unlocked() ) { $thirty->unlock_achievement(); }

if ( $one->counter >= 100 && !$hundred->is_unlocked() ) { $hundred->unlock_achievement(); }

}

Any help would be appreciated.

Thanks.

Skip to toolbar