简体   繁体   English

如何在会员个人资料页面之外使用此buddypress函数“ bppp_progression_block($ user_id)”

[英]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. 我正在基于buddypress 2.0创建一个wordpress小部件。 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. 我已经为小部件编写了主要代码,并且正在使用此功能bppp_progression_block($user_id)在边栏中输出进度条。 The function is from another plugin called buddypress-profile-progression. 该功能来自另一个名为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: 这是我的wordpress小部件的主要代码:

$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. 它不是BuddyPress函数,而是BuddyPress Profile Progression插件。 So it's better to ask that plugin author. 所以最好去问那个插件作者。 Its support is here: https://wordpress.org/support/plugin/buddypress-profile-progression 它的支持在这里: https : //wordpress.org/support/plugin/buddypress-profile-progression

This is what worked for me: 这对我有用:

In bppp-template.php change lines 50-52 from: 在bppp-template.php中,将第50-52行更改为:

     $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: 在第67行更改:

$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: 在第71-73行更改:

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: 将118从:

 $user_id = bppp_get_user_id($user_id);

to: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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