#5666 closed defect (bug) (fixed)
"Settings > Profile" hidden field doesn't list all field IDs
Reported by: | r-a-y | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | 2.0 |
Component: | Extended Profile | Keywords: | dev-feedback has-patch commit |
Cc: |
Description
If you're on your "Settings > Profile" Page, we output a hidden field to keep track of the number of xprofile field IDs that are rendered:
<input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
The problem with this is bp_the_profile_group_field_ids()
only recognizes the last profile group loop and not all profile groups.
Case-in-point, when there is more than one xprofile group, only the fields from the last xprofile group are listed in the hidden field. This means that a user is unable to set the visibility for any field in the first profile field group.
To fix this, I wanted to get rid of the bp_the_profile_group_field_ids()
function when rendering the hidden field, but that might lead to backpat issues for themes that are already using this template.
So the attached patch:
- Adds a filter to
bp_get_the_profile_group_field_ids()
- Records all the field IDs when on a user's "Settings > Profile" page using the new
bp_xprofile_settings_record_all_group_field_ids()
function - Overrides the
bp_get_the_profile_group_field_ids()
value with the recorded value
If there is going to be an interim 2.0.2 release, this should also be part of that.
Let me know what you think.
Attachments (2)
Change History (10)
#3
@
10 years ago
but leave it in/look for it's data in the POST submission as a backwards compatibility fix?
That's possible, but I prefer my technique because it's simpler. I'm happy to be overruled by a majority though :)
#4
@
10 years ago
- Keywords dev-feedback added
This needs more dev-feedback from another core dev, please.
#5
@
10 years ago
- Keywords has-patch added; needs-patch removed
r-a-y, your suggested solution is clever, but I'm with Paul that it seems a bit overengineered for our edge case. I'd rather put a real fix in place for the problem (which is that bp_the_profile_group_field_ids()
is the incorrect function to use here) and then build a backward compatibility layer on top of the fix, rather than leaving the broken status quo in place and then engineering a layer on top to fix it. (Does that make sense?)
Anyway, 5666.02.patch is my suggested solution. Basically, don't use bp_the_profile_group_field_ids()
anymore. Use bp_the_profile_field_ids()
instead, which gets all field IDs available in the $profile_template
loop. r-a-y, as you note, there is backward compatibility issue with sites that have overridden the template; I've chosen to fix that in a very direct way, inside of bp_xprofile_action_settings()
. The backpat fix is a bit ugly, but I'd rather have the ugliness relegated to the backpat fix and keep the rest of the logic as elegant as possible. What do you think?
Storing data in the global at different parts of the loop like this seems a bit overcomplicated. Did you consider your idea to re-work it by removing
bp_the_profile_group_field_ids()
, but leave it in/look for it's data in the POST submission as a backwards compatibility fix?