• Resolved Diabolo

    (@cebuss)


    Hi folks

    Running the latest version of UM. For my use case I’m looking to exclude the logged in member showing up in the directory e.g. if “George” is looking to find someone not much point in him being shown in the results.

    Been hunting for a while to find some code but coming up empty (coding not being my forte not making much sense of what I see in the source code sadly). Appreciate it if someone could point me in the right direction.

    ——–

    Enhancement suggestion to UM team for a future release – Ideally this functionality would be a per directory setting as other use cases would require the logged in member being included e.g. if you had a directory listing all members of departments.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @cebuss

    You can try this custom code to exclude the logged-in user from the Member Directory result globally.

    
    add_filter("um_prepare_user_query_args", function( $query_args, $directory_data ) {
       $query_args['exclude'][ ] = get_current_user_id();
      return $query_args;
    }, 10, 2);
    

    You can add the code to your theme’s function.php file.

    Let us know this works.

    Regards,

    Thread Starter Diabolo

    (@cebuss)

    @champsupertramp

    Many thanks, works perfectly.

    I really need to get my head around this stuff; past couple of weeks very little has sunk in … need to start at the beginning I think.

    Your help much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude logged in user from directory’ is closed to new replies.