Page 1 of 1

Echo Role name.

PostPosted: September 3rd, 2011, 7:34 pm
by bakinblack
I have been working on this forever and searching the forms and all around the web and cannot seem to get any answers on this. I am hoping someone can help here. All I am trying to do it echo the current logged in user's role, but I dont want it to say the actually role I wanna replace them with "Inactive" or "Active" like so.

Billy, Your Time will Expire on:
Sunday January 1st, 2012

Your account is currently set to: subscriber
(If the user is set role subscriber I want the text displayed to say "Inctive"}


Billy, Your Time will Expire on:
Sunday January 1st, 2012

Your account is currently set to: s2member_level2
(If the users role is set to s2member_level2 I want "Active Displayed)

I am using this code in my functions.php

Code: Select all
function get_user_role() {
   global $current_user;

   $user_roles = $current_user->roles;
   $user_role = array_shift($user_roles);

   return $user_role;
}


and using this in my footer.php where the message is shown to the users.

Code: Select all
<?php echo get_user_role(); ?>


I hope someone can help me with this issue Ive been trying my best to figured it on my own but need someone to lead me in the right direction.

Re: Echo Role name.

PostPosted: September 3rd, 2011, 10:21 pm
by Cristián Lávaque
You can try this:

Code: Select all
Your account is currently set to: <?php echo (S2MEMBER_CURRENT_USER_ACCESS_LEVEL == 0 ? 'Inactive' : 'Active'); ?>



WP Admin -> s2Member -> API / Scripting -> s2Member PHP/API Constants -> S2MEMBER_CURRENT_USER_ACCESS_LEVEL