WordPress.org

Forums

Role Scoper
Get the user role in page template (2 posts)

  1. Jay Kanakiya
    Member
    Posted 2 years ago #

    I have got a page template where I would like to show all the users with their current role defined in the role Scaper.
    Here is the php code

    <?php
    		$authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
    		if($authors):
    		foreach($authors as $author):
    		?>
    		<div class='author' id='author-<?php the_author_meta('user_login', $author->post_author); ?>'>
    			<h3><?php the_author_meta('display_name', $author->post_author); ?></h3>
    
    			<div class='description'>
    				<?php echo get_avatar(get_the_author_meta('user_email', $author->post_author), 80); ?>
    				<p><?php the_author_meta('description', $author->post_author); ?></p>
    				<p><?php the_author_meta('number', $author->post_author); ?></p>
    				<p><?php
    					$user = new WP_User( $author->post_author);
    				if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    				foreach ( $user->roles as $role )
    					echo $role." ";
    					}
    				 ?>
    				</p>
    			</div>

    The display names and others perfectly but the echo $role gives output as administrator , contributor not the semantic names I've assigned in role scoper

    http://wordpress.org/extend/plugins/role-scoper/

  2. Kevin Behrens
    Member
    Plugin Author

    Posted 1 year ago #

    Documentation is not currently available, but this topic will point you to sample code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags