2013-10-09 48 views
2

有來電cubepoints點下組BuddyPress的功能topic.php發佈的一個好朋友在這裏計算器:呼叫Cubepoints排名的BuddyPress的函數

add_filter('bp_get_the_topic_time_since_last_post','bp_forum_extras_get_the_topic_time_since_last_post'); 

add_action('bp_get_the_topic_post_poster_avatar', 'topic_poster_avatar'); 
function topic_poster_avatar($avatar) { 
preg_match_all('/user-([0-9]+)-avatar/', $avatar, $m); 
$id = $m[1][0]; 
if ($count = get_user_meta($id, 'cpoints', 1)) 
    return $avatar . '<div class="cp-avatar-counter"><center><span class="number">' . $count . '</span> Points</center></div>'; 
return $avatar; 

}

我想知道你知道調用cubepoints的函數是buddypress的函數麼?下面的代碼用於BB press not buddypress。應該使用cp_module_ranks_getRank來調用cubepoints的rank,但是我怎樣才能將它變成像上面那樣的函數?

<?php echo cp_module_ranks_getRank(bp_displayed_user_id()); ?> 

回答

0

如果我們不知道要在哪裏調用它,我們不能建議鉤子或過濾器。

我猜你想在BP成員循環? 如果是這樣,請查看該模板中的do_action掛鉤,編寫函數並返回cp_module_ranks_getRank(bp_get_member_user_id())的結果。

+0

試過 - > add_filter('bp_get_the_topic_time_since_last_post','bp_forum_extras_get_the_topi c_time_since_last_post'); add_action('bp_get_the_topic_post_poster_avatar','topic_poster_avatar');函數topic_poster_avatar($ avatar){pre-_match_all('/ user - ([0-9] +) - avatar /',$ avatar,$ m); $ id = $ m [1] [0]; if($ count = get_user_meta($ id,'cpoints',1)) return $ avatar。 if(function_exists('cp_module_ranks_getRank'))&& $ user-> ID){echo'

'.cp_module_ranks_getRank($count).'‌​
';返回$ avatar; } –

+0

這不適用於這個嗎? –