|
/ Documentation /Custom Code Snippets/ How to Hide Admins or Specific Users from the Member Directory

How to Hide Admins or Specific Users from the Member Directory

The Member Directory in SureDash displays a list of registered members in your portal. By default, it shows all users, including administrators and portal managers.

If you want to control who appears in the directory, SureDash provides two filters that let you hide specific users or user roles without any manual configuration.

This guide covers both available filters and how to add them to your site.

Snippet 1: Hide All Administrators and Portal Managers

Use this filter when you want only regular members (the suredash_user role) to appear publicly in the directory, keeping staff accounts out of the roster.

1. Copy the Filter Code

<?php
/**
 * Hide administrators and portal managers from the SureDash Member Directory.
 *
 * Useful when you want only members (suredash_user role) to appear publicly,
 * keeping staff accounts out of the roster.
 */
add_filter( 'suredash_membership_directory_exclude_admins', '__return_true' );

Snippet 2: Hide Specific Users by User ID

Use this filter to exclude individual users by their WordPress user ID. This is useful for hiding test accounts, bots, or any profile that should not appear in the directory.

1. Copy the Filter Code

<?php
/**
 * Exclude specific users from the SureDash Member Directory.
 *
 * @param int[] $user_ids Existing list of user IDs to exclude.
 * @return int[] Updated list of user IDs to exclude.
 */
add_filter( 'suredash_membership_directory_excluded_user_ids', function ( $user_ids ) {
    // Replace 12 and 47 with the user IDs you want to hide.
    return array_merge( $user_ids, [ 12, 47 ] );
} );

Replace 12 and 47 with the actual WordPress user IDs you want to hide. You can find a user’s ID under Users in your WordPress admin.

2. Add the Code to Your Site

To safely add either snippet, use a custom code plugin or your theme’s functions.php file. We recommend using the Code Snippets plugin.

Steps:

  1. Go to Plugins > Add New, search for Code Snippets, and install it.
  2. Go to Snippets > Add New.
  3. Give the snippet a title, such as Hide Admins from Member Directory.
  4. Paste the code from above.
  5. Click Save Changes and Activate.

For more details, follow this guide: How to Add Custom PHP Code to Your WordPress Site

Conclusion

That’s it! With these two filters, you have full control over who appears in the SureDash Member Directory. Use the first filter to hide all admins and portal managers at once, or use the second to target specific user IDs.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

On this page
Scroll to Top