0

im using buddypress/bbpress on my website.

Im using some code inside while statment to create a $html to return and fill.

Buddypress have their template functions, but one of them, for default return an echo.

For that reason, when im in the while statment, instead of create $html with tags value inside, that come outside of div

how can i solve that?

What i received :

<img src="http://localhost/replying/wp- 
content/uploads/avatars/6/5ba33f761d115-bpthumb.jpg" class="avatar user-6- 
avatar avatar-50 photo" width="50" height="50" alt="joao" />string(15) "<a 
href=""></a>"

Code:

while(bp_group_membership_requests()) {
bp_group_the_membership_request();
$a = '<a href="' . '">' . bp_group_request_user_avatar_thumb() . '</a>';
}

Objective:

"<a href=""><img src="http://localhost/replying/wp- 
content/uploads/avatars/6/5ba33f761d115-bpthumb.jpg" class="avatar user-6- 
avatar avatar-50 photo" width="50" height="50" alt="joao" /></a>"

Budypress function:

/**
 * @since 1.2.0
 *
 * @return mixed|void
 */

function bp_group_member_domain() {
echo bp_get_group_member_domain();


function bp_get_group_member_domain() {
    global $members_template;

    /**
     * Filters the group member domain for the current user in the loop.
     *
     * @since 1.2.0
     *
     * @param string $value Domain for the current user.
     */
    return apply_filters( 'bp_get_group_member_domain', bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) );
}
}
0

Look at bp_group_request_user_avatar_thumb() in this file /bp-groups/bp-groups-template.php.

It has a filter hook.

In your filter function, add the $html parameter and set it to false and it should return just an url to the avatar. Then you can wrap it in a href and img tag manually.

Or you could write a call directly to bp_core_fetch_avatar.

Take a look at this function bp_core_fetch_avatar in /bp-core/bp-core-avatars.php.

  • Thanks. I will check.. Im new with wordpress and PHP, but how you do to discover that things? what step u did to find the hooks etc? – roger taht Sep 29 '18 at 2:24
  • I just search thru the codebase for a function name or google it, and examine the results. btw- if the answer was helpful, please accept it: stackoverflow.com/help/someone-answers – shanebp Sep 29 '18 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.