How to use this buddypress function "bppp_progression_block($user_id)" outside a member's profile page

367 views Asked by At

I'm creating a wordpress widget based on buddypress 2.0. This widget will simply output displayed user's progress bar and percentage in a side bar.

I've already written the main code for the widget and I'm using this function bppp_progression_block($user_id) to output the progress bar in a side bar. The function is from another plugin called buddypress-profile-progression. The function is defined in this plugin.

How can I make that function work outside a member's profile page?

Here is the main code for my wordpress widget:

$user_id = bp_loggedin_user_id(); // Get the logged in user's id
echo bppp_get_progression_block($user_id); // Output the progress bar
2

There are 2 answers

0
user48978 On

This is what worked for me:

In bppp-template.php change lines 50-52 from:

     $user_id = bp_displayed_user_id($user_id);
     if(!$user_id) return false;

to:

     $current_user = wp_get_current_user();
     $user_id = $current_user->ID;

On line 67 change:

$user_id = bppp_get_user_id($user_id);

to:

$current_user = wp_get_current_user();
$user_id = $current_user->ID;

On lines 71-73 change:

if(bp_is_my_profile()){
    $title = '<a title="'.bppp_get_caption($user_id).'" href="'.bppp_get_link($user_id).'">'.$title.'</a>';
}

to just:

$title = '<a title="'.bppp_get_caption($user_id).'" href="'.bppp_get_link($user_id).'">'.$title.'</a>';

Change 118 from:

 $user_id = bppp_get_user_id($user_id);

to:

$current_user = wp_get_current_user();
     $user_id = $current_user->ID;
0
Slava Abakumov On

It's not a BuddyPress function, but BuddyPress Profile Progression plugin. So it's better to ask that plugin author. Its support is here: https://wordpress.org/support/plugin/buddypress-profile-progression