30 pointsStarting to get into this DEV thingI'm new here
dpyster
Member
—
2nd July 2010 (1 year ago)
Perhaps this isn't the right forum to ask this question, since it's not directly related to a WPMUdev theme or plug-in, but it's worth a shot...
I would like to "lock" an xprofile field, so users cannot change their response once they have completed the registration process. Do you know if it is possible to make an xprofile field "non-editable"?
When I look at the "_bp_xprofile_fields" table in the WordPress database, I see there is a "can_delete" value, but that doesn't seem to "lock" the field.
Perhaps this isn't the right forum to ask this question, since it's not directly related to a WPMUdev theme or plug-in, but it's worth a shot...
I would like to "lock" an xprofile field, so users cannot change their response once they have completed the registration process. Do you know if it is possible to make an xprofile field "non-editable"?
When I look at the "_bp_xprofile_fields" table in the WordPress database, I see there is a "can_delete" value, but that doesn't seem to "lock" the field.
6593 pointsLike some sort of WPMU DEV GodExceptionally helpfulLifetime member
Keeper of the Dark Chocolate
—
5th July 2010 (1 year ago)
#
Gotta admit that with my typing, I;m very much against this. Too easy to make mistakes or typos. But I can see where this could be used.
First things I thought of was maybe there was an edit_profile flag. Nothing in bp's schema.php file that looks good to me. (Actually there's very little in there. Rather surprised.)
I flipped though the bp-xprofile.php file though and noticed this function xprofile_screen_edit_profile:
if ( !bp_is_my_profile() && !is_site_admin() )
return false;
Find the bp_is_my_profile function, stick in the following near the top and it should disallow editing:
return false;
One thing comes to mind right off though. You may have to have access to this function when a profile is first created. I;m not in a position to test this (We don;t have any bp installs) so you may have to test this first.
And if your the site admin, you should still have access.
Wow, thanks for your help @drmike! I really appreciate you digging into the guts of BuddyPress!
I found the bp_is_my_profile function defined in bp-core-templatetags.php:
function bp_is_my_profile() {
global $bp;
if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
$my_profile = true;
else
$my_profile = false;
return apply_filters( 'bp_is_my_profile', $my_profile );
}
I'm a bit hesitant to add a return false; here, since it seems lots of other functions rely on bp_is_my_profile (and I'm not even sure where the best place to add the return false; would be). I also think this would disable editing for all of the xprofile fields, whereas I would like to disable editing for just certain fields.
@drmike Thanks for pursuing this further! This is getting a bit complicated for something that should be relatively simple and straightforward, but I will continue looking into it.
Responses (7)
Lead Developer — 3rd July 2010 (1 year ago) #
Don't know of a plugin but here is the place to look:
http://wordpress.org/extend/plugins/tags/buddypress
Member — 5th July 2010 (1 year ago) #
I've looked there with no luck. Thanks though!
Keeper of the Dark Chocolate — 5th July 2010 (1 year ago) #
Gotta admit that with my typing, I;m very much against this. Too easy to make mistakes or typos. But I can see where this could be used.
First things I thought of was maybe there was an edit_profile flag. Nothing in bp's schema.php file that looks good to me. (Actually there's very little in there. Rather surprised.)
I flipped though the bp-xprofile.php file though and noticed this function xprofile_screen_edit_profile:
http://trac.buddypress.org/browser/trunk/bp-xprofile.php#L187
Take a look a couple of lines down to this:
Find the bp_is_my_profile function, stick in the following near the top and it should disallow editing:
return false;One thing comes to mind right off though. You may have to have access to this function when a profile is first created. I;m not in a position to test this (We don;t have any bp installs) so you may have to test this first.
And if your the site admin, you should still have access.
Hopefully that will work.
Member — 5th July 2010 (1 year ago) #
Wow, thanks for your help @drmike! I really appreciate you digging into the guts of BuddyPress!
I found the bp_is_my_profile function defined in bp-core-templatetags.php:
function bp_is_my_profile() {global $bp;
if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
$my_profile = true;
else
$my_profile = false;
return apply_filters( 'bp_is_my_profile', $my_profile );
}
I'm a bit hesitant to add a return false; here, since it seems lots of other functions rely on bp_is_my_profile (and I'm not even sure where the best place to add the return false; would be). I also think this would disable editing for all of the xprofile fields, whereas I would like to disable editing for just certain fields.
Keeper of the Dark Chocolate — 5th July 2010 (1 year ago) #
edit: I just saw this:
http://trac.buddypress.org/browser/trunk/bp-xprofile.php#L97
bp_core_new_subnav_item which adds in an "Edit Profile" function. Is there a method to remove subnav items?
reedit: Yup: http://trac.buddypress.org/browser/trunk/bp-core.php#L869
bp_core_remove_subnav_item removes a menu item.
Not sure of usage though.
Member — 7th July 2010 (1 year ago) #
@drmike Thanks for pursuing this further! This is getting a bit complicated for something that should be relatively simple and straightforward, but I will continue looking into it.
Keeper of the Dark Chocolate — 7th July 2010 (1 year ago) #
Not a problem.
It really looks like no one has really looked into this feature. Google'ing just pulls up the svn's for the most part.
Become a member