[buddypress-trac] [BuddyPress] #4275: BP 1.6beta1 : xprofile metas default_visibility and allow_custom_visibility not saved when field is created
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Tue Jun 19 11:19:10 UTC 2012
#4275: BP 1.6beta1 : xprofile metas default_visibility and allow_custom_visibility
not saved when field is created
--------------------------+-------------------------------
Reporter: imath | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: XProfile | Version:
Severity: normal | Keywords: reporter-feedback
--------------------------+-------------------------------
Hi,
1st : congratulations for the great work on this new release (1.6 beta 1)
2nd : I've noticed that when the field is first created then the 2 metas :
allow_custom_visibility and default_visibility are not set, you need to
edit the field after its creation to save the 2 metas.
It seems that when the field is first created, the $field_id is not set so
the function bp_xprofile_update_field_meta( $field_id = NULL ,
'default_visibility', $_POST['default-visibility'] ) is not storing the
meta in DB. When editing the $field_id is set and everything is ok.
I've tried this fix :
in /buddypress/bp-xprofile/admin/bp-xprofile-admin.php :
at line 260 :
{{{
if ( !$field_temp_id = $field->save() ) {
}}}
then in the 2 if statements that stores the visibility meta :
{{{
if ( !empty( $_POST['default-visibility'] ) ) {
$field_id = isset( $field_id ) ?
$field_id : $field_temp_id ;
bp_xprofile_update_field_meta(
$field_id, 'default_visibility', $_POST['default-visibility'] );
}
if ( !empty( $_POST['allow-custom-
visibility'] ) ) {
$field_id = isset( $field_id ) ?
$field_id : $field_temp_id ;
bp_xprofile_update_field_meta(
$field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] );
}
}}}
After that, it seems to work.
3rd : I think it would be better to delete the xprofile meta created for
fields if the field is deleted by the admin so in the same file in the
function xprofile_admin_delete_field, i suggest to add this line before
the do_action( 'xprofile_fields_deleted_field', $field );
{{{
bp_xprofile_delete_meta( $field_id, 'field' );
}}}
Thanks for the great work on this beta ! Going back to test it :)
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4275>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list