Support » Plugin: Bainternet User Ranks » [Plugin: Bainternet User Ranks] Tried PHP code in PHP widget and in theme – no dice…

  • Resolved famousb

    (@famousb)


    i’ve installed and activated this plugin, and have tried putting the recommended code:

    <?php $baur_plugin = new baur_Plugin();
    $user_rank = $baur_plugin->ba_get_user_points($user_id,true);
    echo "title: ". $user_rank['title'] .
    "<br />Points: " . $user_rank['points'];?>

    in a PHP code widget in my sidebar, and also directly in my theme. Neither actually shows stats for posts or the title.

    What else needs to be done to get this to work?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Bainternet

    (@bainternet)

    You need to set the $user_id in order to get results, for example if you want results for the current logged-in user the your widget code should look like this:

    //first check if a user has loogged-in
    if (is_user_logged_in()){
    	// then get the current user id using  get_currentuserinfo();
    	global $current_user;
    	get_currentuserinfo();
    	//then use the plugins class: and pass the current  user ID
    	$baur_plugin = new baur_Plugin();
    	$user_rank = $baur_plugin->ba_get_user_points($current_user->ID,true);
    	echo "title: ". $user_rank['title'] .
    	"<br />Points: " . $user_rank['points'];
    }

    what about for users not logged in?

    for user info while in a post by another user, i used:

    get_the_author_meta( 'ID' )

    in place of

    $current_user->ID

    Plugin Author Bainternet

    (@bainternet)

    @famousb as long as you pass an actual user id this will work, the plugin keeps score for users and can’t keep score for guests. so if you want to display a rank and title of a registered user to guests it ok. and if you are using the plugin within the loop the you can just use:

    $post->post_author
    instead of

    get_the_author_meta( 'ID' )
    //or
    $current_user->ID

    paulson101

    (@paulson101)

    I really need to be able to show a list of the top rated people on a site I am doing. Could you show me how to show a list to users if there is no one logged in please!

    Plugin Author Bainternet

    (@bainternet)

    you don’t need anyone to be logged in, just get a list of your users ids and for each one you can use:

    $baur_plugin = new baur_Plugin();
    $user_rank = $baur_plugin->ba_get_user_points($user_id,true);
    echo "title: ". $user_rank['title'] ."<br />Points: " . $user_rank['points'];

    and each time change the $user_id.

    as for top rated you will need wait for the next update.

    paulson101

    (@paulson101)

    I would really really appreciate a top rated. It is a very key part of the website I am setting up right now. And to my knowledge you are the only guy with this type of plugin.

    Do you have an estimate for how long before it is completed?

    Plugin Author Bainternet

    (@bainternet)

    @paulson101 done, check out the new version 1.3.0
    which has a new method to get top ranked and also a shortcode functionally for single user and top ranked user list.

    for usage instructions head to the faq section

    paulson101

    (@paulson101)

    That looks really good! However I think I am doing something wrong with the shortcodes. they dont seem to give any values. I would love the php code that would give me a list of say the top 10 ranked users?

    I love the unlimited titles feature, that is super helpful!

    thanks for your hard work!

    Plugin Author Bainternet

    (@bainternet)

    @paulson101 like i said

    for usage instructions head to the faq section

    it has an example of top ranked php template tag usage.

    paulson101

    (@paulson101)

    haha, I went there before and they weren’t up for me. I see them now! this is excellent. However the shortcodes still do not work for me, but the PHP code did so that is awesome!

    Plugin Author Bainternet

    (@bainternet)

    care to provide some input on what exactly didn’t work with the shortcodes ?

    paulson101

    (@paulson101)

    well I have tried the shortcodes in posts, widgets, and in html/php templates. and they just show up as regular text?

    also when I use the code:

    <?php $baur_plugin = new baur_Plugin();
    $top_users = $baur_plugin->get_top_users(5);
    foreach ($top_users as $user){
    $user_info = get_userdata($user[‘user_id’]);
    echo $user_info->user_login . “
    title: “. $user_rank[‘title’] . “
    Points: ” . $user_rank[‘points’];
    echo “
    “;
    }
    ?>

    it shows a list of users,
    each user has the same amount of points as the person that is logged in,
    and it doesn’t show if everyone is logged out?

    Any ideas?

    Plugin Author Bainternet

    (@bainternet)

    yes i have an idea!

    you are using $user_rank which is not in the scope change your code to this:

    <?php $baur_plugin = new baur_Plugin();
    $top_users = $baur_plugin->get_top_users(5);
    foreach ($top_users as $user){
        $user_info = get_userdata($user['user_id']);
        echo $user_info->user_login . "title: ". $user['title'] ."Points: " . $user['points'];
    }
    ?>
    Fernando

    (@demolishman)

    Hi Bainternet! I need your help, as I am using your plugin. But am facing a little problem changing it to READ the ID of registered User Commenters.

    http://wordpress.org/support/topic/comment-author-ranks-close-to-being-done-need-help?replies=2#post-2160901

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Bainternet User Ranks] Tried PHP code in PHP widget and in theme – no dice…’ is closed to new replies.