Home / eCommerce / WWLC – Default Wholesale Leads list to sort by registration date (newest first)
Duplicate Snippet

Embed Snippet on Your Site

WWLC – Default Wholesale Leads list to sort by registration date (newest first)

1. Navigate to your site: Go to your WP Admin dashboard.
2. Apply the snippet: Paste the code snippet above into your site using a plugin like WPCode Lite or within your child theme's functions.php file.
3. Verify results: Navigate back to the Wholesale Leads page and confirm if the newest registrants are now automatically appearing at the top of the list

Code Preview
php
<?php
  /* Default Wholesale Leads list to sort by registration date (newest first) */
add_action( 'pre_user_query', function( $user_query ) {
      if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
          return;
      }
      if ( false === strpos( $_SERVER['REQUEST_URI'] ?? '', '/wwlc/v' ) ) {
          return;
      }
      if ( false !== strpos( $user_query->query_orderby, 'user_login' ) ) {
          $user_query->query_orderby = 'ORDER BY user_registered DESC';
      }
  } );

Comments

Add a Comment