• Resolved BingoBingo

    (@bingobingo)


    I want a list of all users who meet either condition1 or condition2. The list is sorted by lastname. For the query I use the following code:

    $args = array(
        'meta_query'    => array(
            'relation' => 'OR',
            0 => array(
                'key'       => 'user_thema1',
                'value'     => $kate_name,
                'compare'   => '='
            ),
            1 => array(
                'key'     => 'user_thema2',
                'value'   => $kate_name,
                'compare' => '='
            )
        ),
        'meta_key'      => 'last_name',
        'order'         => 'ASC',
        'orderby'       => 'meta_value'
    );
    $user_query = new WP_User_Query( $args );

    All users are displayed. If a condition is fulfilled, the list is unsorted. If no condition is satisfied, the list is sorted.

    If I take only one condition or two conditions with AND connect, the result is OK.

    What’s wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_user-query: relation OR and sort’ is closed to new replies.