WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 3.6 get_users function wonkiness (1 post)

  1. Nikki Blight
    Member
    Posted 12 months ago #

    Interesting oddity when I upgraded to 3.6 this morning. A plugin I wrote uses the get_users() function to fetch users that are assigned to one of the roles in a given list. It had been working fine right up until the upgrade.

    I finally tracked the problem down to the "fields" parameter of the get_users() function. For some reason, when I was using that parameter, an empty result set was returned. Take it out, and it works just fine.

    Code snippet is below for reference. I'm not sure if this is a bug, or if something changed about the way one is supposed to use the get_users() function.

    $meta_query = array('relation' => 'OR');
    foreach($add_roles as $role) {
    	$meta_query[] = array(
    				'key' => $table_prefix.'capabilities',
    				'value' => $role,
    				'compare' => 'like'
    			);
    }
    
    //get all eligible users
    $args = array(
    		'meta_query' => $meta_query,
    		'orderby' => 'display_name',
    		'order' => 'ASC',
    		'fields' => array('ID, display_name'),
    );
    
    $users = get_users($args);

Reply

You must log in to post.

About this Topic

Tags

No tags yet.