Skip to:
Content
Pages
Categories
Search
Top
Bottom

Trigger function on submitting “edit profil” form / filter


  • bd146082-ovh
    Participant

    @bd146082-ovh

    Hi,

    I want to send my users to the top of the page after they click on “Save changes” when editig their profile informations in buddypress. As I don’t want to modify the plugin’s core files, I looked for filters and found one in buddypress’ “functions.php”.
    The thing is I absolutely don’t understand how this works. I spent 4 hours trying to sort this out but I’m giving up now.(I do understand how generic filters work though)
    Here are the pieces of codes I have been looking at :

    FUNCTIONS.PHP

    function bp_nouveau_get_submit_button( $action = ” ) {
    if ( empty( $action ) ) {
    return false;
    }

    /**
    * Filter the Submit buttons to add your own.
    *
    * @since 3.0.0
    *
    * @param array $value The list of submit buttons.
    *
    * @return array|false
    */
    $actions = apply_filters( ‘bp_nouveau_get_submit_button’, array(
    ‘members-profile-settings’ => array(
    ‘before’ => ‘bp_core_xprofile_settings_before_submit’,
    ‘after’ => ‘bp_core_xprofile_settings_after_submit’,
    ‘nonce’ => ‘bp_xprofile_settings’,
    ‘attributes’ => array(
    ‘name’ => ‘xprofile-settings-submit’,
    ‘id’ => ‘submit’,
    ‘value’ => __( ‘Save Changes’, ‘buddypress’ ),
    ‘class’ => ‘auto’,
    ),

    ) );

    if ( isset( $actions[ $action ] ) ) {
    return $actions[ $action ];

    }

    TEMPLATE TAGS.PHP

    function bp_nouveau_submit_button( $action ) {
    $submit_data = bp_nouveau_get_submit_button( $action );
    if ( empty( $submit_data[‘attributes’] ) || empty( $submit_data[‘nonce’] ) ) {
    return;
    }

    if ( ! empty( $submit_data[‘before’] ) ) {

    /**
    * Fires before display of the submit button.
    *
    * This is a dynamic filter that is dependent on the “before” value provided by bp_nouveau_get_submit_button().
    *
    * @since 3.0.0
    */
    do_action( $submit_data[‘before’] );
    }

    $submit_input = sprintf( ‘<input type=”submit” %s/>’,
    bp_get_form_field_attributes( ‘submit’, $submit_data[‘attributes’] ) // Safe.
    );

    // Output the submit button.
    if ( isset( $submit_data[‘wrapper’] ) && false === $submit_data[‘wrapper’] ) {
    echo $submit_input;

    // Output the submit button into a wrapper.
    } else {
    printf( ‘<div class=”submit”>%s</div>’, $submit_input );
    }

    Now, what I want to do is just add for example “#top” to the URL triggered by the submit button so that the user goes back to the top even if he/she didn’t fill some mandatory fiels and tha the form is not really “sent”.

    Thanks in advance 🙂

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar