Skip to:
Content
Pages
Categories
Search
Top
Bottom

Field groups in registration


  • JetZ
    Participant

    @yetza

    I found this question in this forum, which is my question also. But the answer (this code) doesn’t work for me. The question is really old, and so is the code. The current register.php has changed quite a bit.

    I did get some guidance from the pastebin code and tried different variations. Here’s a shortened version:

    <?php do_action( 'bp_after_account_details_fields' ); ?>
    
            <?php /***** Extra Profile Details ******/ ?>
            <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
                <?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
                <div class="register-section" id="profile-details-section">
    
                    <h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
    
                    <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
                    <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => true ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
                    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
                        <div class="editfield">
    
                            <?php
                            $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
                            $field_type->edit_field_html();
    
                            do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
    
                            if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
                                <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
                                    <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
                                </p>
    
                                <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
                                    <fieldset>
                                        <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
                                        <?php bp_profile_visibility_radio_buttons() ?>
    
                                    </fieldset>
                                    <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
                                </div>
                            <?php else : ?>
                                <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
                                    <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
                                </p>
                            <?php endif ?>
    
                            <?php do_action( 'bp_custom_profile_edit_fields' ); ?>
    
                            <p class="description"><?php bp_the_profile_field_description(); ?></p>
    
                        </div>
    
                    <?php endwhile; ?>
    
                    <!-- <?php $fields_ids[]= bp_get_the_profile_group_field_ids();?> -->
    
                    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
    
                    <?php endwhile; endif; endif; ?>
    
                    <?php do_action( 'bp_signup_profile_fields' ); ?>
                </div><!-- #profile-details-section -->
    
                <?php do_action( 'bp_after_signup_profile_fields' ); ?>
            <?php endif; ?>
    
            <?php /***** Extended Profile Fields: About Me (group 9) ******/ ?>
            <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
                <?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
                <div class="register-section" id="profile-details-section">
    
                    <h4><?php _e( 'About Me', 'buddypress' ); ?></h4>
    
                    <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
                    <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 9, 'fetch_field_data' => true ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
                    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
                        <div class="editfield">
    
                            <?php
                            $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
                            $field_type->edit_field_html();
    
                            do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
    
                            if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
                                <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
                                    <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
                                </p>
    
                                <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
                                    <fieldset>
                                        <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
                                        <?php bp_profile_visibility_radio_buttons() ?>
    
                                    </fieldset>
                                    <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
                                </div>
                            <?php else : ?>
                                <p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
                                    <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
                                </p>
                            <?php endif ?>
    
                            <?php do_action( 'bp_custom_profile_edit_fields' ); ?>
    
                            <p class="description"><?php bp_the_profile_field_description(); ?></p>
    
                        </div>
    
                    <?php endwhile; ?>
    
                    <!-- <?php $fields_ids[]= bp_get_the_profile_group_field_ids();?> -->
    
                    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
    
                    <?php endwhile; endif; endif; ?>
    
                    <?php do_action( 'bp_signup_profile_fields' ); ?>
                </div><!-- #profile-details-section -->
    
                <?php do_action( 'bp_after_signup_profile_fields' ); ?>
            <?php endif; ?>

    Basically I reused the original profile field loop and made it specific to the group field I want. I have 5 other groups I need in the register form. And repeating the initial loop for each one makes them display beautifully in the register form, but when I fill them out and click submit only the last group is displayed in the profile. It’s like only the last bit of code is being executed, so each loop is overwriting the previous one. In the forums I read that placement of <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" /> is very important but after playing around with it I still have nothing.

    I also found this but have no idea of where or how to use it.

    Any guidance will be greatly appreciated.

  • You must be logged in to reply to this topic.
Skip to toolbar