Skip to:
Content
Pages
Categories
Search
Top
Bottom

Sending multiple xProfile forms


  • polywebjeff
    Participant

    @polywebjeff

    Hey! I have a My Profile page containing 2 forms in which these are the fields to fill to modify your informations. Those are separated in two because they are in 2 seperate groups of xprofile profile fields. I want to send both groups of fields at the same time with the same “save changes” button. I know jQuery will not work since the page refresh made by the submit prevent the first form from sending. I also know I have to call an Ajax call for that. Can someone help me find that call please? Here is my code, shortened:

    if ( bp_has_profile( 'profile_group_id=1' ) ) :
        while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
            <form action="<?php bp_the_profile_group_edit_form_action(); ?>" method="post" id="profile-edit-form1" class="standard-form <?php bp_the_profile_group_slug(); ?>">
                <?php
    
                /** This action is documented in bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php */
                do_action( 'bp_before_profile_field_content' ); ?>
    
                <h2><?php printf( __( "My Profile", 'buddypress' ), bp_get_the_profile_group_name() ); ?></h2>
    
                <div class="clear"></div>
    
                <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
                    <div<?php bp_field_css_class( 'editfield' ); ?>>
                        <fieldset>
    
                            <?php
                            $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
                            $field_type->edit_field_html();
    
                            /**
                             * Fires before the display of visibility options for the field.
                             *
                             * @since 1.7.0
                             */
                            do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
                            ?>
    
                            <?php
    
                            /**
                             * Fires after the visibility options for a field.
                             *
                             * @since 1.1.0
                             */
                            do_action( 'bp_custom_profile_edit_fields' ); ?>
    
                        </fieldset>
                    </div>
    
                <?php endwhile; ?>
    
                <?php
    
                /** This action is documented in bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php */
                do_action( 'bp_after_profile_field_content' ); ?>
    
                <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
                <?php wp_nonce_field( 'bp_xprofile_edit' ); ?>
    
        <?php endwhile; endif; ?>
    
    <div class="submit">
            <input type="button" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php esc_attr_e( 'Save Changes', 'buddypress' ); ?> " onclick="submitForms()"/>
        </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
    if ( bp_has_profile( 'profile_group_id=2' ) ) :
        while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
            <form action="<?php bp_the_profile_group_edit_form_action(); ?>" method="post" id="profile-edit-form2" class="standard-form <?php bp_the_profile_group_slug(); ?>">
                <?php
    
                /** This action is documented in bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php */
                do_action( 'bp_before_profile_field_content' ); ?>
    
                <h2><?php printf( __( "About me", 'buddypress' ), bp_get_the_profile_group_name() ); ?></h2>
    
                <div class="clear"></div>
    
                <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
                    <div<?php bp_field_css_class( 'editfield' ); ?>>
                        <fieldset>
    
                            <?php
                            $field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
                            $field_type->edit_field_html();
    
                            /**
                             * Fires before the display of visibility options for the field.
                             *
                             * @since 1.7.0
                             */
                            do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
                            ?>
    
                            <?php
    
                            /**
                             * Fires after the visibility options for a field.
                             *
                             * @since 1.1.0
                             */
                            do_action( 'bp_custom_profile_edit_fields' ); ?>
    
                        </fieldset>
                    </div>
    
                <?php endwhile; ?>
    
                <?php
    
                /** This action is documented in bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php */
                do_action( 'bp_after_profile_field_content' ); ?>
    
                <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
                <?php wp_nonce_field( 'bp_xprofile_edit' ); ?>
    
        <?php endwhile; endif; ?>
    
        <div class="submit">
            <input type="button" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php esc_attr_e( 'Save Changes', 'buddypress' ); ?> " onclick="submitForms2()"/>
        </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>
    
  • You must be logged in to reply to this topic.
Skip to toolbar