PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Echo Role name.

s2Member Plugin. A Membership plugin for WordPress®.

Echo Role name.

Postby bakinblack » September 3rd, 2011, 7:34 pm

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.
User avatar
bakinblack
Registered User
Registered User
 
Posts: 7
Joined: September 2, 2011

Re: Echo Role name.

Postby Cristián Lávaque » September 3rd, 2011, 10:21 pm

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
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron