0

I have this code:

<?php
  class UPME_List_Cards {

  public $upme_options;


  public function __construct() {
    global $upme;
    add_shortcode('upme_latest_members_list', array($this,'latest_members_list'));
}

public function latest_members_list($atts){
    global $upme_template_loader,$upme_list_card_params;
    extract( shortcode_atts( array(
        'limit'   => 10 ,
        'user_role' => '',
        'template' => 'members_icon_mini',
      ), $atts ) );

    $admin_users = get_users('role=administrator&orderby=registered&order=DESC');
    $admin_users_list = array();
    foreach ($admin_users as $admin_user) {
        array_push($admin_users_list,$admin_user->ID);
    }

    $display = '';

    $args = array(
                'exclude'=> $admin_users_list,
                'number' => $limit,
                'orderby' => 'registered',
                'order'   => 'desc',
                'meta_query' => array(
                    'relation' => 'AND',
                    0 => array(
                        'key'     => 'upme_user_profile_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        ),
                    1 => array(
                        'key'     => 'upme_approval_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        ),
                    2 => array(
                        'key'     => 'upme_activation_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        )
                )
            );

    if($user_role != ''){
        $args['role'] = $user_role;
    }

    $users_query = new WP_User_Query( $args );
    $results = $users_query->get_results();
    $upme_list_card_params['results'] = $results;

    ob_start();

    switch($template){
        case 'members_icon_mini':                
            $upme_list_card_params['css_class'] = 'upme-list-card-default-mini';
            $upme_template_loader->get_template_part('members-icon-mini');        
            break;

        case 'members_icon_mini_rounded':                
            $upme_list_card_params['css_class'] = 'upme-list-card-default-mini-rounded';
            $upme_template_loader->get_template_part('members-icon-mini');        
            break;
    }

    $display = ob_get_clean();

    return $display;       
}

}

$upme_list_cards = new UPME_List_Cards();

So, how to order user alphabetically by name in UPME plugin?

  • Hello @Diana - Welcome to the WordPress Development community! Unfortunately, questions regarding 3rd-party products are considered off-topic here as they require extremely intimate knowledge of extremely specialized code in order to answer well. Your question would be best addressed in the 3rd-party's official support channels. Please review the "How to Ask" page in our help center for more information about what constitutes a good question for our community. – bosco Apr 29 '16 at 21:10
  • @bosco It's a get_users() and WP_User_Query call… – kaiser May 3 '16 at 16:52
  • @kaiser aye it is! I was only commenting on the appropriateness of the content: the question, both in title and one-sentence body paraphrasing the title, specifically addresses a proprietary 3rd-party plugin. Beyond that, the vast majority of the question is comprised of a portion of that premium plugin's codebase, which seems as though it might violate licensing terms. This question is significantly disparate from "how can I sort users alphabetically", in my mind. – bosco May 3 '16 at 20:31
  • 1
    I guess I didn't really phrase that properly in my original comment... I admit it was something of a canned response - my apologies =/ – bosco May 3 '16 at 20:32
0

Diana you must change line of code in this array

 $args = array(
                'exclude'=> $admin_users_list,
                'number' => $limit,
                'orderby' => 'registered',
                'order'   => 'desc',
                'meta_query' => array(
                    'relation' => 'AND',
                    0 => array(
                        'key'     => 'upme_user_profile_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        ),
                    1 => array(
                        'key'     => 'upme_approval_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        ),
                    2 => array(
                        'key'     => 'upme_activation_status',
                        'value'   => 'ACTIVE',
                        'compare' => '='
                        )
                )
            );

This line 'orderby' => 'registered', you will change registerd to 'name' so this line would look like this 'orderby' => 'name', and also change this line from desc to asc 'order' => 'desc', change it to 'order' => 'asc',.

  • actually i change the lines that you say, but doesn't work – Diana Apr 29 '16 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.