Skip to:
Content
Pages
Categories
Search
Top
Bottom

exclude users from member listing


  • inderpreet2018
    Participant

    @inderpreet2018

    Hi,

    I want to exclude users from members listing whose status is pending and denied.
    Like I have total users on my site is 35, and from which 11 are pending and 1 is denied. So I want to show only 23 users on member listing page. Also exclude that users from total count.

    Help me.

Viewing 9 replies - 1 through 9 (of 9 total)

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    BuddyPress never lists pending and denied members. Are you using any other system to verify them?

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Yes, I am using “New User approve” plugin, as I am using “Memberpress” plugin to maintain registrations.

    How I approve new users from buddypress?


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    You need to disable activation mail and then those users will not be able to activate their account themselves and then you can go and do it manually from users screen.

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Hi,

    Can you let me know,
    1. For which I need to disable email, memberpress or something else?
    2. how I disable activation email?
    3. how I activate them manually?


    Prashant Singh
    Participant

    @prashantvatsh

    Members directory is from BuddyPress. Buddypress always send an activation email when a new user registers from it’s register page. If you are not following that process then certainly you are using memberpress process and have to repair the count always or else let them login and when they will access Buddypress pages they will be listed automatically.

    Thanks


    inderpreet2018
    Participant

    @inderpreet2018

    Thanks for reply.

    I used custom code to achieve my goal. And it’s all working fine now.


    Prashant Singh
    Participant

    @prashantvatsh

    Great 🙂


    reinhardtjohn
    Participant

    @reinhardtjohn

    What did you do to hide the Pending users from Members Search directory?


    inderpreet2018
    Participant

    @inderpreet2018

    Hi,

    I added the code to exclude denied and pending users from member directory, listing and forum count. It works fine 2 days before. But now it’s not.
    2019-03-19_1051
    2019-03-19_1055

    Total memebers are 122 but it shows 119. Even I run the repair tool.

    Here is my code
    ///// Remove pending/denied users from the member directory////////
    add_filter( ‘bp_after_has_members_parse_args’, ‘buddydev_exclude_users_by_role’ );
    function buddydev_exclude_users_by_role( $args ) {
    // do not exclude in admin.
    if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) {
    return $args;
    }

    $excluded = isset( $args[‘exclude’] ) ? $args[‘exclude’] : array();
    if ( ! is_array( $excluded ) ) {
    $excluded = explode( ‘,’, $excluded );
    }

    $role = ‘subscriber’;// change to the role to be excluded.
    $user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );

    $excluded = array_merge( $excluded, $user_ids );
    $args[‘exclude’] = $excluded;

    return $args;
    }

    /********** Excluded ADmin and pending/denied users from members listing page ***************/
    function exclude_total_users($count){

    $role = ‘subscriber’;// change to the role to be excluded.
    $user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );

    $user_excluded = count($user_ids);

    return ($count – $user_excluded – 1);
    }
    add_filter(‘bp_get_total_member_count’,’exclude_total_users’);

    /******* Exclude pending/denied and admin users from forum stats ***********/

    function exclude_users_forum($user_count){

    $role = ‘subscriber’;// change to the role to be excluded.
    $user_ids = get_users(array( ‘role’ => $role, ‘fields’ => ‘ID’, ‘meta_query’ => array(‘relation’ => ‘OR’, array(‘key’ => ‘pw_user_status’, ‘value’ => ‘pending’), array(‘key’ => ‘pw_user_status’, ‘value’ => ‘denied’)) ) );

    $user_excluded = count($user_ids);

    return ($user_count – $user_excluded – 1);
    }
    add_filter(‘bbp_get_total_users’,’exclude_users_forum’);
    /*******************/

    Can you help me to sort it out, what is the issue??

    Thanks in advance.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar