Reload the page after sending a message

Hi,
how can I force the page to refresh after each message sending?
Thanks for your help

guess you can modify into ‘redirect’ => false,

Thanks,
but where?

I tried this, but it doesnt work:

add_filter(
    'hivepress/v1/forms/message_send/response',
    'my_theme_message_send_response',
    10,
    2
);

function my_theme_message_send_response( $response, $form ) {
    if ( $response['success'] ) {
        $response['script'] = 'setTimeout(function() { location.reload(); }, 1000);';
    }

    return $response;
}

Hi,

Please try to use this hook hivepress/v1/forms/message_send and set the form parameter redirect to true and remove the message parameter.

1 Like

If anyone needs it, here is a code that works well

add_filter(
    'hivepress/v1/forms/message_send',
    function( $form ) {
        $form['redirect'] = true;
        unset( $form['message'] );

        return $form;
    }
);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.