Search code examples
wordpressfilterregistrationfrontend

Wordpress custom register form errors filters and prev values


I created a front end registration form, I used the filters 'registration_errors' to customize the messages.

After WP detects the error and use 'wp-redirect' to return to the registration page and display an error if the email or the user exists for example.

My question is: how I can keep the previous values that generated the error.

¿JS?

Thanks in advance!


Solution

  • To keep values in the form after the error message:

    function my_register_sesion (){
        session_start();
        $_SESSION['key_login']=$_REQUEST['user_login'];
        $_SESSION['key_email']=$_REQUEST['user_email'];
    }
    add_action ('register_post', 'my_register_sesion');
    

    My inputs form should be as follows:

    <input type="text" name="user_login" id="user_login" class="input" value="<?php echo $_SESSION['key_login'];?>">
    <input type="text" name="user_email" id="user_email" class="input" value="<?php echo $_SESSION['key_email'];?>">
    

    Thank you David!