Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been studying the source of a plugin which calls the following function to display an image inside of a user's profile (BuddyPress). My aim is to call the exact same function to do the same thing (display an image) BUT inside of the Member's Loop.

require ( dirname( __FILE__ ) . '/includes/buddypress-verified-profile.php' );


function bp_show_verified_badge() { 
  global $bp;


    $is_verified = get_user_meta($bp->displayed_user->id, 'bp-profile-verified', true);

    $file = dirname(__FILE__) . '/buddypress-verified.php';
    $plugin_url = plugin_dir_url($file);

    if ( $is_verified['profile'] == 'yes' ):
        ?>
            <?php if (  $is_verified['image'] == null ): ?>
            <span id="bp-verified"><img src="<?php echo $plugin_url; ?>/images/1.png">
            <?php else : ?>
                <span id="bp-verified"><img src="<?php echo $plugin_url; ?>/images/<?php echo $is_verified['image'] ?>.png">
            <?php endif ; ?>

            <?php if (  $is_verified['text'] == null ): ?>
                <span class="v-text"><?php _e('Verified User', 'bp-verified'); ?></span></span>
            <?php else : ?>
                <span class="v-text"><?php echo $is_verified['text'] ?></span></span>
            <?php endif ; ?>

<?php
    endif;
}
add_action( 'bp_before_member_header_meta', 'bp_show_verified_badge' );
add_action( 'bp_members_directory_item', 'bp_show_verified_badge' );

function bp_verified_insert_head() {
?>

What is the right way to use this function to output the image in the members loop?

share|improve this question
add comment

1 Answer

Use BuddyPress native functions, like bp_get_user_meta(). I'm pretty sure that this plugin saves its infor in wp_usermeta table, so it can be accessible via that function. You just need to see how that field is called.

if ( bp_has_members() ) {
    while ( bp_members() ) {
        bp_the_member();
        $user_avatar = bp_get_user_meta( bp_get_member_user_id(), 'avatar', true );
        // now output this image as you wish and depending on the image path/value
        echo '<img src="'.$user_avatar'" alt="" />
    }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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