Title: Sticky Users?
Last modified: August 31, 2016

---

# Sticky Users?

 *  [Sajjad Ali](https://wordpress.org/support/users/the-rock/)
 * (@the-rock)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/sticky-users/)
 * I have this shortcode to display a loop of user avatars with order by registration
   date.
 *     ```
       function Profiles() {
       	$args = array(
       	'orderby' => 'registered',
       	'order' => 'DESC',
       	'fields' => 'all_with_meta',
       	);
       	$user_query = new WP_User_Query( $args );
       	if ( ! empty( $user_query->results ) ) {
       	foreach ( $user_query->results as $user ) {	?>
   
       	<div class="grid-item user-img-<?php echo $user->ID; ?>" rel="<?php echo $user->ID; ?>">
       	<a href="<?php echo $website; ?>" rel="<?php echo $user->ID; ?>" target="_blank"><?php echo get_avatar( $user->ID, 100 ); ?></a>
       	</div>
       	<?php }
       	} else {
       		echo 'No users found.';
       	}
       }
       add_shortcode('profiles', 'Profiles');
       ```
   
 * If any user role changes to `sticky` (a custom role) then that users move to 
   top of the list. Default orderby should stay as registered for all other users
   in the loop. Once `sticky` user role is removed, it goes back to normal sorting.
 * I gave it quite a bit thought and maybe if i can combine two arguments in a single`
   Wp_User_Query` that might do the trick?
 * For example `$sticky_args` have `role__in => 'sticky'` and `$simple_args` have
   all others `roles => 'subscriber', 'customer', 'author'` OR `role__not_in => '
   sticky'` argument. Then combining this `Wp_User_Query` in a way that `$user_query-
   >results` shows `$sticky_args` users list first and then `$simple_args` user 
   list after that in the loop. I tried several codes and trying to think if statements
   but nothing works so far. Would appreciate the help.

The topic ‘Sticky Users?’ is closed to new replies.

## Tags

 * [wp_user_query](https://wordpress.org/support/topic-tag/wp_user_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Sajjad Ali](https://wordpress.org/support/users/the-rock/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/sticky-users/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
