Support only during business hours : Monday to friday, from 8:30 am – 5:30 pm CEST

Due to the decrease in our staff due to vacations, our response time may be longer.

Be sure we're doing our best to manage your topic as soon as possible.

Removing roles from directory

This topic is resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • alex
    Participant
    • 81 Topics
    • 259 Posts
    @abourne

    After MUCH effort finding scripts and snippets to remove admin and a particular role -I found one – but it ended up causing problems so disabled.

    Left without a solution, I found this awesome plugin.

    Please suggest it in your docs to help future Gwangi fans like me who want to exclude Admin roles and the like.

    PLUS it allows restriction of profile viewing! the only plugin I can find which does so.

    BP Custom Functionalities

    Under 10 active downloads – not sure how its not been found…

    Here’s the snip used in any case:

    /**
     * Exclude Users from BuddyPress Members List by WordPress role.
     *
     * @param array $args args.
     *
     * @return array
     */
    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     = 'administrator';// change to the role to be excluded.
        $user_ids = get_users( array( 'role' => $role, 'fields' => 'ID' ) );
     
        $excluded = array_merge( $excluded, $user_ids );
     
        $args['exclude'] = $excluded;
     
        return $args;
    }
     
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_role' );
    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1675 Posts
    @themosaurus

    Hi @abourne,

    Thank you for sharing this plugin with our community. #SharingIsCaring ❤️
    We hope that it might help others further customize their BuddyPress website.

    When useful, we won’t hesitate to share the link.

    All the best,

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

The topic ‘Removing roles from directory’ is closed to new replies.

Troubleshooting Demo Imports

You're trying to setup your theme but you're experiencing errors when importing the demo content? Or you've just followed the setup guide but your website doesn't look exactly like our demo? These are common issues for which you can find easy and quick fixes.

Happy With our Support So Far?

Feel free to review our theme on Themeforest! It helps us making our products more known to new potential customers, which allow us more time to improve the quality and develop new features. #SharingIsCaring ❤️

Discover MatchPress

Skip • Like • Super-Like

Add powerful matching features like Member likes, skips, super likes, conditional private messaging and much more.

Setup Your Cera or Gwangi powered Community Website and Turn it into an iOS and Android App

15% discount for Cera users

To unleash the full power of your Cera or Gwangi theme, we have partnered with the Zipline team. Your community website can now be fully setup and turned into your very own custom app for iOS and Android.

Whether you've newly acquired the theme or already got your site up and running, Zipline got you covered. And we got you an incredible discount.

Holiday, Weather & Festive effects
to pimp your WordPress Site