Page 1 of 1

Showing user roles after login?

PostPosted: November 23rd, 2011, 8:30 pm
by tripleaaadelay
Hi guys,

I'm trying to show the s2Member user roles on my theme after users login.

In my header.php I can see this array:

$role = array(
10 => __( 'Administrator' , 'cosmotheme' ) ,
7 => __( 'Editor' , 'cosmotheme' ) ,
2 => __( 'Author' , 'cosmotheme' ) ,
1 => __( 'Contributor' , 'cosmotheme' ) ,
0 => __( 'Subscriber' , 'cosmotheme' ),
'' => __( 'Subscriber' , 'cosmotheme' )
);

How can I add the s2member roles?

Thanks,
Aaron

Re: Showing user roles after login?

PostPosted: November 24th, 2011, 1:44 am
by Bruce C
You should be able to do something along these lines:

Code: Select all

<?php
global $wp_roles;
    foreach ( 
$wp_roles->role_names as $role => $name )
                {
                        if (
current_user_can($role))
                                echo 
$role;
                }

?>

Re: Showing user roles after login?

PostPosted: November 24th, 2011, 8:57 am
by tripleaaadelay
Thanks for the tip Ace, but I'm really a novice. I messaged the theme company and they said just add the roles straight in to the array. What would that look like using the example above... or can you explain your version in a bit more detail?

Thx,
Aaron