Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restrict xProfile group to Administrator-only write access

  • @dwdutch

    Participant

    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’ ) ?>

    <div class=”submit”>

    <input type=”submit” name=”profile-group-edit-submit” id=”profile-group-edit-submit” value=”<?php _e( ‘Save Changes’, ‘buddypress’ ) ?> ” />

    </div>

    with the following lines:

    <?php do_action( ‘bp_after_profile_field_content’ ) ?>

    <!–

    ****** 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: ?>

    <div class=”submit”>

    <input type=”submit” name=”profile-group-edit-submit” id=”profile-group-edit-submit” value=”<?php _e(

    ‘Save Changes’, ‘buddypress’ ) ?> ” />

    </div>

    <?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.

Viewing 1 replies (of 1 total)
  • @latinosamorir

    Participant

    Problem with that though is that if Buddypress changes the structure, this won’t work in the future?

Viewing 1 replies (of 1 total)
  • The topic ‘Restrict xProfile group to Administrator-only write access’ is closed to new replies.
Skip to toolbar