Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Followup to Add xprofile field Vibility “Admin only” #5317

@michaeltransmissions

Participant

shanebp — I followed your suggestion and it worked like a charm. I also had to add some code to my functions.php file to be able to redirect calls to the WP Profile page to the BP Profile page because editing the the files you suggested didn’t affect restrict the fields on the WP Profile page (code for this below, if anyone wants).

My only question is the following – would changes to the files in the bp-templates directory get overwritten if I update the BP plugin? If so, it would be nice to find an alternative way to do this, but otherwise I just need to know so I can incorporate a restore of the code changes from a backup to my upgrade workflow document for this site.

Thanks,
Michael

add_action ('init' , 'prevent_profile_access');
 
function 	prevent_profile_access(){
   		if (current_user_can('manage_options')) return '';  //if admin, exit
		
		//everyone else, redirect to the bp profile page, not the wp profile page!
   		if (strpos ($_SERVER ['REQUEST_URI'] , 'wp-admin/profile.php' )){
      		wp_redirect (bp_loggedin_user_domain());
 		 }
 
}
Skip to toolbar