简体   繁体   中英

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

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

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM