• Resolved F R

    (@frosado)


    Hello,

    We are encountering a bug when we use a redirect parameter in the URL for the page where our registration form lives. If we include a redirect parameter on the URL which brings the user to the registration form, then upon registration the user WILL be created in WordPress correctly, but the user is NOT automatically logged in.

    So for example, if a user visits:

    https://boxofficefunding.com/login/?redirect_to=google.com

    They can successfully register and will be redirected to Google.com. HOWEVER, they are not automatically logged into the site. (In our real use case the user is redirected to a dynamic page within our site; I am using Google.com here just as a simple example.)

    Note that if the user visits instead:

    https://boxofficefunding.com/login/

    They are able to successfully register and upon registration they ARE automatically logged in and redirected to the default redirect page specified in the UM Settings for that User Role.

    So we know the redirection is working on both cases (URL with or without redirect parameters). The bug or problem seems to be that if the URL contains a redirect parameter, then when the user submits their registration they are NOT automatically logged into the site. This is breaking our workflow and needed user experience.

    Can anyone please help us with this issue? We need the user logged in automatically into their account when they register so they can continue their workflow.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter F R

    (@frosado)

    Follow-up:

    I tried using the plugin “Auto Login New User After Registration” to solve the login problem, and it successfully allowed me to automatically log in users after registration, but it introduced a new error where the new user’s first name and last name are NOT saved to their WP user profile in the back-end.

    I then removed the “Auto Login New User After Registration” plugin and added the code below to functions.php. Once again, new users are automatically logged in after they register, but they lack their first name and last name in their profile.

    Somehow UM is blocking the new user registration from saving first name and last name to the database.

    I did a conflicts test and it is the UM plugin which blocks first name and last name. Running the site without UM results in all fields being saved to the database.

    When I remove the code below the first and last names are saved to the database but users are once again not automatically logged in if the referring URL to the registration page contains a ?redirect parameter in the URL.

    Any ideas for how to auto-register while using redirect parameters in the URL -or- how to successfully save first name and last name to the user profile when using an auto login plugin or function like the one below?

    Thank you!

    function auto_login_new_user( $user_id ) {
            wp_set_current_user($user_id);
            wp_set_auth_cookie($user_id);
                // You can change home_url() to the specific URL,such as 
            //wp_redirect( 'https://www.wpcoke.com' );
            wp_redirect( home_url() );
            exit;
        }
        add_action( 'user_register', 'auto_login_new_user' );
    Thread Starter F R

    (@frosado)

    Solved it. I added the following code to functions.php. This method of auto-login did not conflict with Ultimate Member and successfully logged in the user after registration while capturing the first name and last name fields correctly in the WordPress user profile.

    Just passing it along for anyone else who may have this issue and in case it helps fix UM’s conflict with other methods of auto login when URL redirect parameters are used.

    function auto_login_new_user( $user_id ) {
            wp_set_current_user($user_id);
            wp_set_auth_cookie($user_id);
        }
        add_action( 'user_register', 'auto_login_new_user' );
    Jad

    (@jihadkhouri)

    Thank you for sharing your solution.
    Could you please advise where exactly should i add it ?

    I went to plugins -> plugin editor -> chosen -> Ultimate member -> then to includes file which contains :
    1-class-functions.php
    2-um-dependencies-functions.php
    3-um-short-functions.php
    or maybe there is other folder to add your code too?
    Which folder to add you code to ?

    thank you for your support.

    Thread Starter F R

    (@frosado)

    You can add it to functions.php or to your child theme.

    I am actually using a code snippet plugin to have more control over the functions I add to the site, and to protect them from site/theme updates.

    Hope this helps!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug in UM User Registration’ is closed to new replies.