5 years, 1 month ago
This may not be the most elegant solution but perhaps it will be useful to others. I use WP=2.9.2 & BP 1.2.1 and a simplistic child theme based on the BuddyPress Default 1.2.1 theme.
I want to have certain xProfile fields that are visible to others but could only be administered by the site administrator (e.g. is their membership payment up-to-date). I decided the easiest strategy would be to prevent a user from having access to the “SAVE CHANGES” button on the admin page of a specific xProfile group named “Admin-only”.
1) i copied a file from the default theme: BLOG_BASE/wp-content/plugins/buddypress/bp-themes/bp-default/members/single/profile
2) I placed the file into my child theme: BLOG_BASE/wp-content/themes/MY_CHILD_THEME/members/single/profile/edit.php
3) Within the file, I replaced these lines (from around line #104):
<?php do_action( ‘bp_after_profile_field_content’ ) ?>
<input type=”submit” name=”profile-group-edit-submit” id=”profile-group-edit-submit” value=”<?php _e( ‘Save Changes’, ‘buddypress’ ) ?> ” />
with the following lines:
****** RESTRICT ADMINISTRATION OF ADMIN-ONLY XPROFILE GROUP TO ADMINISTRATORS
****** BY REMOVING THE “SAVE CHANGES” BUTTON UNLESS USER IS A SITE ADMINISTRATOR
<?php if ( bp_get_the_profile_group_name() == “Admin-only” && !is_site_admin() ) : ?>
<h4><?php printf( __( “Only Administrators can save changes in this Profile Group”, “buddypress” ) ); ?></h4>
<?php else: ?>
<input type=”submit” name=”profile-group-edit-submit” id=”profile-group-edit-submit” value=”<?php _e(
‘Save Changes’, ‘buddypress’ ) ?> ” />
<?php endif; ?>
<!– ****** END OF ADMIN-ONLY RESTRICTION –>
4) From the Dashboard: BuddyPress –> Profile Field Setup create a new Field Group called “Admin-only”
Now, any field added into this group will have the restriction that its value can only be changed by a site-administrator.
As I said, not elegant, but i hope it helps.
4 years, 11 months ago
Problem with that though is that if Buddypress changes the structure, this won’t work in the future?
Follow BuddyPress on Twitter •
Contact Us •
Terms of Service