Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: BP Avatars in bbPress


John James Jacoby
Keymaster

@johnjamesjacoby

Well, while the GF is in the shower, I’ll quick do this… Burt this is aimed directly at you, since I gather most others won’t want to do this kind of thing…

oci_bb_group_forums.php:


This prevents wrong inclusion order when using deep forum integration.

if (defined(BACKPRESS_PATH))
require_once( BACKPRESS_PATH . '/class.ixr.php' );

This will return ALL user info, in the event that bbGroups does not exist yet for that user.

function oci_get_userdata($u){
$u = (int) $u;
$user = bb_get_user($u);
if ($user->bbGroups) {
return stripslashes_deep((array)$user->bbGroups);
} else {
return stripslashes_deep((array)$user);
}
}

oci_bp_group_forums.php:


This prevents wrong inclusion order when using deep forum integration.

if (!defined(BBDB_NAME))
require_once(ABSPATH . WPINC . '/class-IXR.php');

This is how I passed the user info over from xprofile to bbGroups:

/**
* oci_get_user_filter()
*
* Live example of how to use the filter mechanism to add info to the data going across to bbpress
* This filter adds the user's forums and forums where the user is staff into the $user array
* @return
* @param associative array $user from oci_get_user()
*/
function oci_get_user_filter($user){
$users_group_info = oci_get_users_group_info($user['id']);

$user['users_forums'] = $users_group_info['forum_ids'];
$user['user_is_staff'] = $users_group_info['staff_ids'];

$user['custom_title'] = bp_get_field_data('Custom Title', $user['id']);
$user['signature'] = bp_get_field_data('Signature', $user['id']);
$user['aim'] = bp_get_field_data('AIM', $user['id']);
$user['yahoo'] = bp_get_field_data('Yahoo!', $user['id']);
$user['gtalk'] = bp_get_field_data('GTalk', $user['id']);
$user['msn'] = bp_get_field_data('MSN', $user['id']);
$user['jabber'] = bp_get_field_data('Jabber', $user['id']);
$user['icq'] = bp_get_field_data('ICQ', $user['id']);

return $user;
}
add_filter('oci_get_user','oci_get_user_filter',10,1);

oci_bb_custom.php


How I transfer the username (just in case fullname hasn’t been edited from wordpress.org transfer – see above oci_get_userdata changes):

function oci_user_name($u){
$bp_user = oci_get_userdata($u);
if ($bp_user['fullname']) {
return $bp_user['fullname'];
} else {
return $bp_user['display_name'];
}
}

bbpress/active-theme/functions.php


What I added to make the custom functions go:

add_filter('get_user_profile_link', 'bppro_user_profile_link', 10, 2);
function bppro_user_profile_link($link, $uid) {
$user = bb_get_user($uid);
return(bb_get_option('wp_siteurl').'/members/' . $user->user_login);
}

function bppro_user_url() {
global $bp;
return($bp->loggedin_user->domain);
}

function bp_check_title($user) {
$user_id = get_post_author_id();
$user = bb_get_user($user_id);
$user_title = $user->bbGroups['custom_title'];

if ($user_title) {
return $user->bbGroups['custom_title'];
} else {
return;
}
}
add_filter('post_author_title', 'bp_check_title');
add_filter('post_author_title_link', 'bp_check_title');

function post_author_signature() {
$user_id = get_post_author_id();
$user = bb_get_user($user_id);
$user_signature = $user->bbGroups['signature'];

if ($user_signature) {
echo '<p class="post-signature">__________<br />' . $user->bbGroups['signature'] . '</p>';
}
}

bbpress/active-theme/post.php


Displays avatar from BuddyPress if it exists, else bbPress/Gravatar. Also displays hooked data from above functions.php:

<div class="threadauthor">
<dl>
<dt><a class="oci-link" href="<?php echo oci_user_link($bb_post->poster_id); ?>"><?php echo oci_user_name($bb_post->poster_id); ?></a></dt>
<dd><span class="oci-title"><?php $patl = post_author_title_link(); ?></span></dd>
<dd><?php if (oci_user_avatar($bb_post->poster_id)) { echo oci_user_avatar($bb_post->poster_id); } else { post_author_avatar_link(); }?></dd>
</dl>
</div>
<div class="threadpost">
<div class="poststuff">
<?php printf( __('Posted %s ago'), bb_get_post_time() ); ?> <a href="<?php post_anchor_link(); ?>">#</a> <?php bb_post_admin(); ?><?php bb_quote_link(); ?>
</div>
<div class="post">
<?php post_text(); ?>
</div>
<?php post_author_signature(); ?>
</div>

Skip to toolbar