Redirect After Failed Registration to other Page or Section

Question

How i can redirect the failed registration session to other page or url?

Solution on this question seems not working anymore

This is my (NOT) WORKING lines,

add_action('register_new_user', 'binda_register_fail_redirect', 99, 3);

function binda_register_fail_redirect( $sanitized_user_login, $user_login, $user_email, $errors ){
    //this line is copied from register_new_user function of wp-login.php
    $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_login, $user_email );
    //this if check is copied from register_new_user function of wp-login.php
    if ( $errors->get_error_code() ){
        //setup your custom URL for redirection
        $redirect_url = get_bloginfo('url') . '/forgot-password';
        //add error codes to custom redirection URL one by one
        foreach ( $errors->errors as $e => $m ){
            $redirect_url = add_query_arg( $e, '1', $redirect_url );    
        }
        //add finally, redirect to your custom page with all errors in attributes
        wp_redirect( $redirect_url );
        exit;   
    }
}

Any solution or ide?

Thanks!

0
Unggul Kirindi 2 years 2020-10-24T07:10:26-05:00 0 Answers 12 views 0

Leave an answer

Browse
Browse