• Hi,
    is there way to display badges on user profile but his badges, not mine (logged user)? For example:
    my user is “nik” and my friend username is “peter”. When I am logged in (nik) and I open peter’s profile page I see my points. I want to se peter’s points. Ok, I can put username in shortcode, but I have 20+ users and only one “User profile”, so I need unique shortcode to play in “User profile” page and sow badges for that user.
    This is how profile page works: url is /profile/ and if I visit that page, it will show my profile. But, if I open /profile/peter/ I will see peter’s profile details. But, if peter visit /profile/ page, he will see his profile. Every user have /username url.

Viewing 1 replies (of 1 total)
  • If you’re using this with Buddypress, you could do something like placing the following code in a text-widget in the sidebar/ whatever

    <?php 
    	global $bp;
    	$user_id = $bp->displayed_user->id;
        if ( $user_id != 0 ) {
             _e($points = Badgearoo::instance()->api->get_user_points( $user_id ));	
        } else {
    		_e( 'Invalid member profile.', 'badgearoo' );
    	}
    ?>

    It displays the points for the logged in user and uses Badgearoos api to get it. You can make the WordPress text widgets accept php with

    function php_execute($html){
    	if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html);
    	$html=ob_get_contents();
    	ob_end_clean();
        }
    	return $html;
        }
    add_filter('widget_text','php_execute',100);
    • This reply was modified 8 years, 6 months ago by Jonas.
Viewing 1 replies (of 1 total)
  • The topic ‘Show points for user on user page (not for logged)’ is closed to new replies.