Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Codex Issue…Error on Avatar Help Page, Please Resolve

@lookingahead

Participant

Ohhh, GOT IT!!

looks like this code is exactly what is needed….i pasted it into a custom plugin and wa-la…credit goes to the fabulous @prashantvatsh! he replied in the support forum on his plugin (the ‘BP Custom Functionalities’ plugin)…like super quick, with the correct solution to me needing to restrict access to a user’s OWN profile. brilliant!

here’s that support thread:

https://wordpress.org/support/topic/restrict-access-to-users-own-profile/

and here’s the code from prashant that i wound up putting into a custom plugin file and uploading to my site:

add_action( 'wp', 'bp_own_profile_member_redirect' );
function bp_own_profile_member_redirect(){
	if(bp_is_user()){
	    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
	        exit;
	    }
	}
}

thanks again for all your help, @venutius — your help was fundamental to me figuring out the next steps (how the BuddyPress avatars exist and how to get those avatars to show what i wanted without messing with bbPress code)…i am truly grateful for all your assistance!

Skip to toolbar