Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to show multiple profile field groups on register.php?

  • Avatar of jvoss
    jvoss
    Participant

    @jvoss

    I’m desperately trying to figure out how to show all extended profile fields on the registration page organized by the groups field group they belong to. I’ve found the tips on displaying all the profile fields in one large group, but I need the fields to be displayed within their individual groups.

    For example, an “Account Details” section (with the username, password, and email–this already exists), “Profile Details” (with several fields belonging to that group, “Students” (for people registering as students), “Faculty” (for people registering as faculty), etc.

    I know I can have a register.php page with just the base group, then encourage the users to fill out the other fields after they’ve registered, but in my experience many people don’t get around to filling in the other fields. I need them to see the options all on the registration page.

    I thought I had figured out how to do this (it looked great) but when the registration form was submitted, none of the extended fields were saved. I think that has to do with figuring out where to put the “<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="” />”.

    Thank you for whatever help you can give me. My eyes are aching from staring at code for so long. Please help!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Avatar of govpatel
    govpatel
    Participant

    @govpatel

    You will need someone to code the form and add fields in database as that is where all data is saved.

    Avatar of jvoss
    jvoss
    Participant

    @jvoss

    Actually, I’ve already added the fields to the database. And I can code the registration page myself, with a little direction. What I tried already (and this looked great, it just didn’t work) was something along the following line:

    After php do_action( ‘bp_after_account_details_fields’ ) and before php do_action( ‘bp_after_signup_profile_fields’ ) :

    [ I tried pasting the code, but it didn't display. I've put it in a postbin at http://pastebin.com/bQxzDtc8 ]

    It all looked great, was styled beautifully, and all the fields were displayed under their group. However after submitting the form, none of the entered info made it into the database. I’d post the whole register.php page code, but it is very long.

    Avatar of jvoss
    jvoss
    Participant

    @jvoss

    Success! It turns out I was much closer than I thought. I had done some extensive rearranging and adding of divs to the editfield divs, and didn’t have the do_action( ‘bp_custom_profile_edit_fields’ ) in the correct place. I also used some code from @sbrajesh that he posted at http://bpdev.pastebin.com/RLreXE7X that was intended for displaying all profile fields on the profile page.

    To see (and understand) what I was trying to do, you can see it at http://phrstudents.org/register/. For anyone interested in the complete code for my registration page, with all the appropriate php tags, I’ve posted it at http://pastebin.com/XA0Uii3A. Because of the multiple loops and divs I added for styling, it’s pretty long.

    Essentially, for each profile field group I want to display I start each loop with:
    php if ( function_exists( ‘bp_has_profile’ ) ) : if ( bp_has_profile( ‘profile_group_id=1′ ) ) : while ( bp_profile_groups() ) : bp_the_profile_group();

    I change “( ‘profile_group_id=1′ )” to “( ‘profile_group_id=3′ )” or “( ‘profile_group_id=4′ )”, etc.

    I end each loop with:
    php endwhile;
    php $fields_ids[]= bp_get_the_profile_group_field_ids();
    php endwhile; endif; endif;
    input type=”hidden” name=”signup_profile_field_ids” id=”signup_profile_field_ids” value=”php echo implode(“,”,$fields_ids); “

    And somehow, it all works!

    Avatar of junger
    junger
    Participant

    @junger

    @jvoss — are any of your fields required? If so, are they actually forcing users to fill them out?

    I was able to add my 2nd and 3rd profile fields to registration, but the “required” fields can be bypassed without filling them out.

    This looks great! I’m having a truly difficult time getting these profile groups to appear….will definitely be trying this out on a site I’m working on now – http://nextstarathlete.com

    @jvoss – I’m wondering – do these pofile groups also appear within buddypress after you’ve registered?

    I found a much easier solution for this….

    Line 59 of the register.php file contains this code when it’s forming the query to get all the signup fields…

    The ‘profile_group_id=1′ restricts the query to only the base fields. Delete that argument and it should display all the fields. The code looks like:

    Avatar of candy2012
    candy2012
    Member

    @candy2012

    well, that (velomash) will not help much unfortunatelly .. nor will the required fields be cheked or the information for all group fields saved to the database!
    Buddypress is so damn buggy on this one, wonder if they really thought of the purpose of implementing those fileds without proper connection to teh registration form; who the h* (sorry!) will go to fill in the fields if not requested upon registration?

    Avatar of candy2012
    candy2012
    Member

    @candy2012

    @ivoss – God bless you for posting that link! (http://pastebin.com/RLreXE7X)

    I lost days on this already!

    These lines (aroung 150) are CRUCIAL for getting the values posted to the database (basically that `$fields_ids[]` function

    `

    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="” />`

    Avatar of 4ella
    4ella
    Participant

    @4ella

    @ivoss Thank you very much ivoss ! Tomorrow will try to implement it !

    Avatar of junger
    junger
    Participant

    @junger

    @candy2012 just to clarify, the order of the fields should be

    `

    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="” />

    `

    It works great!

    Avatar of pbarnhart
    pbarnhart
    Participant

    @pbarnhart

    Start with:

    <?php $formloop = 0; ?>
    <?php if ( bp_is_active( ‘xprofile’ ) ) : if ( bp_has_profile( ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    <?php
    if (bp_get_the_profile_group_id() != $formloop) {
    $formloop = bp_get_the_profile_group_id();
    $newfieldset = TRUE;
    ?>
    <fieldset id="xprofile_<?php echo bp_get_the_profile_group_slug() ?>">
    <legend><?php echo bp_get_the_profile_group_name() ?></legend>
    <?php
    }
    ?>
    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    <?php$formlist[] = bp_get_the_profile_field_id(); ?>

    —– Continue with the form code —-

    <?php endwhile; ?>
    <?php
    if ($newfieldset == TRUE) {
    $newfieldset = FALSE;
    ?>
    </fieldset>
    <?php
    }
    ?>
    <?php endwhile; endif; endif; ?>
    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php echo implode(",", $formlist); ?>" />

    Avatar of rc183
    rc183
    Participant

    @rc183

    I have juste released my own plugin BP Force Profile : http://wordpress.org/extend/plugins/bp-force-profile/

    Thank you for your help !

Viewing 12 replies - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.