Support

Account

Home Forums Front-end Issues How to relate the WP_User_Query custom fields created in a particular group?

Solving

How to relate the WP_User_Query custom fields created in a particular group?

  • Hi,
    I have created a group of post_types that is related to a custom field within a group. This group is related to the user’s registration, where it marks the checkbox to relate.

    I’m trying to list the user according to the checkbox marked, except that returns nothing and when I remove the meta_query works but without the filter I want.

    I await a solution.

    Thank you for your attention,
    Hugs!

    $args = array (
          'role'           => 'contributor',
            'relation' => 'and',
            'meta_key'       => 'produtos_comercializados',
            'meta_value'     => get_term_by('slug', $_GET['tag'], 'oportunidade-tag')->term_id,
            'meta_compare'   => '=',
          'fields'       => 'all',
       );
    $user_query = new WP_User_Query( $args );
    if ( ! empty( $user_query->results ) ) {
    	foreach ( $user_query->results as $user ) {
    		echo '<li>' . $user->user_login . ' - '.$user->user_email.'</li>';
    	}
    }
  • I am sending screens to assist in troubleshooting.
    thank you!




    • Elliot

    • July 17, 2013 at 2:58 pm

    Hi @bigrecreio

    Thanks for the code and screenshots, but I don’t understand how your code is possible to work.

    You have created a post type, and a custom field which has tags. Is this correct?

    This has no relation to a user, so I don’t think your args and the WP_User_Query object would work.

    Perhaps you could re explain what you are trying to do.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.