Support » Plugin: BP Custom Functionalities » Restrict access to user’s OWN profile…?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Prashant Singh



    Thanks for all the appreciation.

    Please try this snippet:

    add_action( 'wp', 'bp_own_profile_member_redirect' );
    function bp_own_profile_member_redirect(){
    	    global $bp;
    	    $current_user_id = (int) trim($bp->loggedin_user->id);
    	    $member_id  = (int) trim($bp->displayed_user->id);
    	    if (!current_user_can('manage_options') && $current_user_id == $member_id)
                    //Only admins can view their own profile
    	        wp_redirect(site_url()); //you can set any URL here


    THAT DID IT!!!!!!! <3 Okay, this is fantastic. Giving you a 5-star review now!

    I used that code and made it into a custom plugin…which is always fun to do. I think that’s ok to do with this code, right? So far I’ve tested it and it’s all good.

    And the phenomenal thing about this code snippet is that I, as a Keymaster, can still view my own profile — even though other users below my level cannot view their own profile. Which was also something I needed, but your code is so good I didn’t even have to ask for that!

    Thank you, so very much. I am deeply grateful.

    I hope you have a wonderful, wonderful day. <3

    Plugin Author Prashant Singh


    I hope you have a wonderful, wonderful day. <3

    Thanks and same to you.

    Thanks again for the appreciation. Glad to know that it helped you.

    You can put the code anywhere in the functions.php(child-theme) or any custom plugin.


    Plugin Author Prashant Singh


    Marking this resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Restrict access to user’s OWN profile…?’ is closed to new replies.