#4275 closed defect (bug) (fixed)
BP 1.6beta1 : xprofile metas default_visibility and allow_custom_visibility not saved when field is created
Reported by: | imath | Owned by: | |
---|---|---|---|
Milestone: | 1.6 | Priority: | normal |
Severity: | normal | Version: | 1.6 |
Component: | Extended Profile | Keywords: | |
Cc: |
Description
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', $_POSTdefault-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 :)
Change History (6)
#4
follow-up:
↓ 5
@
12 years ago
- Resolution set to fixed
- Status changed from new to closed
imath - Thanks for the tip! In the future, it would be helpful to have these suggestions in patch form; see the "How to submit patches" section at https://core.trac.wordpress.org/ for more details :)
I'm going to mark this ticket fixed and open a new enhancement ticket for the meta deletion issue. #4276
#5
in reply to:
↑ 4
@
12 years ago
Replying to boonebgorges:
imath - Thanks for the tip! In the future, it would be helpful to have these suggestions in patch form; see the "How to submit patches" section at https://core.trac.wordpress.org/ for more details :)
I'm going to mark this ticket fixed and open a new enhancement ticket for the meta deletion issue. #4276
Hi boone, sorry i'm new to this. I'm going to read this section for future suggestions ;) Thanks for the feedback.
(In [6117]) In xprofile_admin_manage_field(), make sure $field_id is set before setting meta
When creating a new profile field, it's necessary to ensure that $field_id is
set, or calls to bp_xprofile_update_meta() and related wrapper functions will
fail. That means that, eg, field visibility settings are not properly stored
on the initial field creation. This changeset fixes the problem by ensuring
that $field_id has been populated before carrying on with the setup routine.
See #4275
Props imath