DanMat Posted May 16, 2013 Share Posted May 16, 2013 (edited) So. I am using a plugin called "simple user rank" which counts the number of comments and displays a different rank. All good. But I don't want my admins/moderators to be displayed as newbies/rookies or any other rank just because they don't comment that much. This is how the plugin works and displays the rank if( !function_exists('get_user_rank') ) { function get_user_rank() { if( !$ranks = get_option('_user_rank_comments_fields') ) return false; $count = get_transient( 'user_rank_comments_' . substr(md5( strtolower(get_comment_author_email( $comment_id )) ),0, ); if ( false === $count ) { global $wpdb; $count = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = %s AND comment_approved = 1' , get_comment_author_email() ) ); set_transient( 'user_rank_comments_' . substr(md5( strtolower(get_comment_author_email( $comment_id )) ),0,, $count ); } foreach( $ranks as $row ) { if( $count >= (int)$row['count'] ) $rank = $row['name']; else break; } return $rank; I want to override the rank displayed for admin and/or moderator like this: if (current_user_can( 'manage_options' )) { echo 'admin' } elseif (current_user_can( 'moderate_comments' )) { echo 'moderator' } endif return $rank Any help is appreciated! Thanks! Edited May 16, 2013 by DanMat Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/ Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 And the problem is? Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430423 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 it doesn't do the trick otherwise I wont be here asking for help. either I don't implement it where I should or I am missing something. Overrall no problem Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430428 Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 You didn't explain very much in your post. Is this the wordpress plugin here? http://wordpress.org/extend/plugins/simple-user-rank-comments/ If you'd said in your first post it was Wordpress, it would be helpful Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430429 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 Yes that's it.I've tried it like this <?php if (current_user_can( 'manage_options' )) { echo 'admin' } elseif (current_user_can( 'moderate_comments' )) { echo 'moderator' } else ( function_exists('get_user_rank') ) echo get_user_rank(); ?> but no luck so far. Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430433 Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 Is current_user_can a Wordpress function or part of this plugin? Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430434 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 a wordpress function. Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430435 Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 Okay, so what happens in your script now? Everyone just gets their rank, you don't see "Admin" at all? And you're logged in as the admin user? Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430436 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 It doesnt change anything. I've tried in n ways but no luck. Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430437 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 displays rank for admin users -> newbie or rookie. or whatever rank is set. Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430438 Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 If you say no luck one more time I'm leaving. It doesn't sound like what you're doing is even the right way to do it. current_user means the user who is logged in, the user viewing the page. So if you are not logged in you will always see the ranks. If you are logged in as admin, everyone will have the name admin. That's what you want? Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430454 Share on other sites More sharing options...
DanMat Posted May 16, 2013 Author Share Posted May 16, 2013 (edited) If you arent logged in you can't view the website. Its a private community. and I know exactly what current_user means i think its pretty straight forward. About what I am trying to do : You have a status of "guru" yeS ? If you were also an admin I would want to display that your status of admin. To all users. If you'd have a moderator status I want to display Moderator for all user not just for the user in cause. If you dont understand what I mean please don't bother to post just to add more posts to the count and get a status of guru. And I can say whatever I want so stop it. Edited May 16, 2013 by DanMat Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430474 Share on other sites More sharing options...
Jessica Posted May 16, 2013 Share Posted May 16, 2013 *eyeroll* Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/278066-trying-to-display-admin-if-is-admin/#findComment-1430486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.