• Hi,

    I’m using the following syntag;

    //search args
    $args = array(
    ‘blog_id’ => $GLOBALS[‘blog_id’],
    ‘orderby’ => ‘login’,
    ‘order’ => ‘ASC’,
    ‘search’ => ‘a-name’,
    ‘count_total’ => false,
    ‘fields’ => ‘all’,
    );

    //get the users and diplay them
    $blog_users = get_users($args);

    Now I get 20+ duplicate user results (one user fits) with unike user ID’s in the objects.

    Database has no dublicate enteries.
    Anny sugestions?

    Kinds regards,
    Sven

Viewing 1 replies (of 1 total)
  • Thread Starter mortydot

    (@mortydot)

    Hi,

    I have still the same problem…

    After some searching, I discovered that this code/search request:

    //search args
    $args = array(
    		'blog_id'      => $GLOBALS['blog_id'],
    		'orderby'      => 'user_nicename',
    		'order'        => 'ASC',
    		'search'       => $search,
    		'count_total'  => true,
    		'fields'       => 'all',
    		'number'       => '',
    		'meta_key'     => '',
    		'meta_value'   => '',
    		'meta_compare' => '',
    		'meta_query'   => array(),
    );
    //get the users and diplay them
    $blog_users = get_users($args);

    Results in this query by the WordPress-core:

    SELECT wp_users . *
    FROM wp_users
    INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
    WHERE ‘1’ = ‘1’
    AND (
    (
    wp_usermeta.meta_key = ‘wp_s2member_subscr_id’
    AND wp_usermeta.meta_value LIKE ‘%asdf%’
    )
    OR (
    wp_usermeta.meta_key = ‘wp_s2member_custom’
    AND wp_usermeta.meta_value LIKE ‘%asdf%’
    )
    OR (
    wp_usermeta.meta_key = ‘wp_s2member_custom_fields’
    AND wp_usermeta.meta_value LIKE ‘%asdf%’
    )
    OR (
    wp_usermeta.meta_key = ‘wp_s2member_notes’
    AND wp_usermeta.meta_value LIKE ‘%asdf%’
    )
    OR (
    wp_usermeta.meta_key LIKE ‘%_name’
    AND wp_usermeta.meta_value LIKE ‘%asdf%’
    )
    OR user_login LIKE ‘%asdf%’
    OR user_nicename LIKE ‘%asdf%’
    OR user_email LIKE ‘%asdf%’
    OR user_url LIKE ‘%asdf%’
    OR display_name LIKE ‘%asdf%’
    )
    AND wp_users.ID
    IN (

    SELECT DISTINCT (
    user_id
    )
    FROM wp_usermeta
    WHERE meta_key = ‘wp_capabilities’
    )
    ORDER BY user_nicename ASC
    LIMIT 0 , 30

    Looking at all those OR fields to search for, I understand that there are so many results. So what am I doing wrong? My goal is to search for all users with that name in them.

    Tanks in advantage,
    Kinds regards,
    Sven

Viewing 1 replies (of 1 total)
  • The topic ‘get_users($args) returns duplicate users’ is closed to new replies.