Edit profile groups on single page
-
Hi,
i want to edit my BuddyPress profile on a single page instead of serveral tabs/pages.
By now, every profile group generates a new tab with an own URL. Even if there is only one field within a group.
Is there any solution to display all groups on a single page? So the user can edit and save all fields without clicking through serveral tabs.
-
At the top of edit.php (yourtheme/buddypress/members/single/profile/edit.php), find this bit near the top:
if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group();
The important part in the snippet above is this function call:
bp_get_current_profile_group_id()
. That grabs the current group ID from the URL, and sets it for the rest of the page. We want to change that bit.Just above the first code snippet I wrote, paste this query to collect all the profile groups into one variable:
$sqlStr = "SELECT *
idFROM
wp_bp_xprofile_groups`”;
$groups = $wpdb->get_results($sqlStr);`Now you can replace
bp_get_current_profile_group_id()
with this:$groups[0]
That will leave you with this:
if ( bp_has_profile( 'profile_group_id=' . $groups[0] ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
Now if you visit any of your edit profile group links, you’ll see all the groups on a single page.
Next, you will probably want to remove the pagination from the page, as it will get included multiple times (since we’re in a while loop), and it is also unnecessary now that we’re showing all groups on one page.
Remove this bit:
<ul class="button-nav"> <?php bp_profile_group_tabs(); ?> </ul>
Hope that works for you.
Hi @graylien,
thanks for your answer!
There is just one problem I have.
Every tab has its own save button which only saves the changes in this “tab”. Even if they are all on the same page.Is there a way to fix this?
Hey Pixelguy,
you raised an issue I had to tackled and thanks to @graylien it works fine.
As you also mentioned I had the save button repeated each “tab” and I found a solution that seems working so far but I would love real tech guy to confirm it’s not a mistake 🙂at the end of the edit.php file we worked on you can find this :
<?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 esc_attr_e( 'Save Changes', 'buddypress' ); ?> " /> </div> <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_field_ids(); ?>" /> <?php wp_nonce_field( 'bp_xprofile_edit' ); ?> </form> <?php endwhile; endif; ?> <?php do_action( 'bp_after_profile_edit_content' ); ?>
what I understand is that it says :
– after the form you call bp_after_profile_field_content
– then you show the button and the hidden fields
– then you close the form
– and you close the loop by endwhile – endifand @graylien gave us a trick to make the loop “looping” for every tab and not only just one so what I did was to take the endwhile -endif closing the loop inside the form and before the button so the button will remain in the form but not repeated as the loop is closed now.
<?php do_action( 'bp_after_profile_field_content' ); ?> <?php endwhile; endif; ?> <div class="submit"> <input type="submit" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php esc_attr_e( 'Save Changes', 'buddypress' ); ?> " /> </div> <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_field_ids(); ?>" /> <?php wp_nonce_field( 'bp_xprofile_edit' ); ?> </form>
I hope that my trick is right and that my explanations are clear as I’m neither a developper nor an native english speaker 🙂
Please come back to me wether if it works,
Cheers,
vincentWell I wrote too fast my answer and didn’t test it properly : it does not work :'(
The page output looks good but it’s not recording the data in the database.
I’ll look forward to solve this and if any specialist wanna come in… welcome,Vincent
@vincefr did you solve it? Or anyone else?
To get all fields on the same tab, you simply add them to the Base tab. Users can then fill in anything from one tab and profile will show only one tab.
This will spare you a lot of time to tweak the original form.
First topic mention: So the user can edit and save all fields without clicking through serveral tabs.
If, as site owner, you create profile field group it is probably because you want some structurized output.Now, before hacking, you have to ask yourself about what you want: structure or UX. And IMHO in this case, the user comes in second position.
Another point of view, if it so “complicated” for user to fill in several tabs, consider your work first and justify why you have so many fields, that your user consider it is a mess to fill them… 😉thanks for your input, @danbp.
There is, of course, a reason why i want it as requested 🙂
On my registration form, i only want to show one field to not bother new users with unnecessary fields. this one field is in my base group.
All other fields are arranged in another group.From my point of view, it doesn’t make sense to show two tabs on the profile-edit page, but it does make sense to show as less fields as possible on the registration page. I think UX comes first today. Customers pay our rent, so we should avoid putting spokes in there wheel. I also think buddypress is doing a pretty bad job here regarding UX (Of course this behavior gives structure, but we pay with UX for it). Since we live in 2015 it shouldn’t be a matter of “hacking” to reduce the amount of inputs and clicks for such “trivial” actions (from a users perspective) like editing a profile.
Is that reason enough? 🙂
Then create a template overload of this file:
buddypress\bp-templates\bp-legacy\buddypress\members\register.phpIn that file, prevent the display of certain fields by checking them by using
bp_get_the_profile_field_id()
orbp_get_the_profile_field_input_name()
in the loop:while ( bp_profile_fields() ) : bp_the_profile_field();
i did it that way and it worked for me. so i now have all my profile fields in one group and display only one of the fields on the registration-page
- The topic ‘Edit profile groups on single page’ is closed to new replies.