Skip to content

Instantly share code, notes, and snippets.

@kaskad88
Last active December 7, 2023 21:46
Show Gist options
  • Save kaskad88/fba279e0ebfa4dbf37f3462688e8af79 to your computer and use it in GitHub Desktop.
Save kaskad88/fba279e0ebfa4dbf37f3462688e8af79 to your computer and use it in GitHub Desktop.
1) Add `random_users` CSS ID for Listing Grid widget https://tppr.me/7S5Xg
2) Add follow code to the functions.php file of child theme:
add_action( 'jet-engine/listing/grid/users-query-args', function( $args, $render ) {
if ( 'random_users' !== $render->get( '_element_id' ) ) {
return $args;
}
$args['orderby'] = 'rand';
return $args;
}, 10, 2 );
add_action( 'pre_user_query', function( $query ) {
if ( 'rand' === $query->query_vars["orderby"] ) {
$query->query_orderby = 'ORDER by RAND()';
}
} );
@kaskad88
Copy link
Author

@xtofr Are you using the Query builder for user listing?

@xtofr
Copy link

xtofr commented Apr 10, 2023

Hi and thanks,
No i'm not, only the users query on the role (membre).
All other query tabs are empty

@kaskad88
Copy link
Author

@xtofr
Please check all the points I wrote above.
If again not successful, please contact our support https://crocoblock.com/help-center/ for guidance in resolving this issue (and mention that you were directed by me and reference this issue.)
thanks.

@xtofr
Copy link

xtofr commented Apr 14, 2023

👌, Thks

@fbeach73
Copy link

followed the advice here also used a simple user query and there is no random returns in the listing grid

@kaskad88
Copy link
Author

@fbeach73 Could you please attach a screen or video of your steps ? Are you using the Query builder for user listing?

@kervis
Copy link

kervis commented Dec 7, 2023

@kaskad88 Is it possible to work with Ajax, or the infinite scroll in jetengine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment