• Hi I want the users created on my site to be able to view other users profiles but not edit it. I am only able to list other users through user role editor but cannot view the full profile

Viewing 2 replies - 1 through 2 (of 2 total)
  • Here is some sample code from Justin Tadlock to list all users and provide a link to their profile page. It is certainly not elegant but it will probably point you in the right direction. Original article here: https://justintadlock.com/archives/2008/06/09/doing-more-with-gravatars-authors-template-page

    <?php
    
    // Get the authors from the database ordered by user nicename
    	global $wpdb;
    	$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename";
    	$author_ids = $wpdb->get_results($query);
    
    // Loop through each author
    	foreach($author_ids as $author) :
    
    	// Get user data
    		$curauth = get_userdata($author->ID);
    
    	// If user level is above 0 or login name is "admin", display profile
    		if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
    
    		// Get link to author page
    			$user_link = get_author_posts_url($curauth->ID);
    
    		// Set default avatar (values = default, wavatar, identicon, monsterid)
    			$avatar = 'wavatar';
    ?>
    
    <div class="post">
    
    	<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
    		<?php echo get_avatar($curauth->user_email, '96', $avatar); ?>
    	</a>
    
    	<h3 class="post-title">
    		<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a>
    	</h3>
    
    	<p>
    		<?php echo $curauth->description; ?>
    	</p>
    
    </div>
    
    		<?php endif; ?>
    
    	<?php endforeach; ?>
    Thread Starter khushboo_s

    (@khushboo_s)

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to allow view all user profile details but not edit’ is closed to new replies.