WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Aleph] Filter user list by role (2 posts)

  1. AnaRita
    Member
    Posted 3 years ago #

    I need to restrict the user list in users.php to users in three custom roles. How and where do I do this?
    Thank you,
    Ana Rita

  2. AnaRita
    Member
    Posted 3 years ago #

    In UserQuery.php

    //TODO: case admins, moderators, commenters, etc.
    		if (!empty($q['user_type'])) {
    			switch($q['user_type']) {
    				case 'authors':
    					$distinct .= 'DISTINCT';
    					$join .= " INNER JOIN $wpdb->posts ON ($wpdb->users.ID = $wpdb->posts.post_author) ";
    					$where .= " AND $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' ";
    					break;
    				        default:
    				        $where .= " AND ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE 'academic')";
    					break;
    			}
    		}

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.