Last active
July 10, 2022 11:08
-
-
Save yuriinalivaiko/4140df34bf283fbbefed80dbcf5a65a5 to your computer and use it in GitHub Desktop.
This code snippet prevents members from being able to see themselves in the member directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Prevent members from being able to see themselves in the member directory. | |
* Add this code to the file functions.php in the active theme directory. | |
*/ | |
function um_pre_users_query_notme( $directory ) { | |
if ( is_user_logged_in() ) { | |
$directory->where_clauses[] = 'u.ID != ' . get_current_user_id(); | |
} | |
} | |
add_action( 'um_pre_users_query', 'um_pre_users_query_notme', 20 ); | |
function um_prepare_user_query_args_notme( $query_args ) { | |
if ( is_user_logged_in() ) { | |
$query_args['exclude'] = get_current_user_id(); | |
} | |
return $query_args; | |
} | |
add_filter( 'um_prepare_user_query_args', 'um_prepare_user_query_args_notme', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is a part of the article Prevent members from being able to see themselves in the member directory.
Documentation: https://docs.ultimatemember.com/
Support forum: https://wordpress.org/support/plugin/ultimate-member/
Support (for customers): https://ultimatemember.com/support/ticket/