• Resolved Paul

    (@pawelszroeder)


    Hi! I have two register forms (wit auto approve). I would like to redirect users to different points depending on the register form.

    I see redirect option in every login form, but I don’t see in register form options.
    There is only redirection option in user role setting.

    How to redirect user to url from specific form? Maybe some function with id of the form?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @pawelszroeder

    You can try the following code snippet:

    add_action( 'um_registration_complete', 'um_031122_redirect_after_registration', 10, 2 );
    function um_031122_redirect_after_registration( $user_id, $args ){
    
        if( 5 == $args['form_id'] ){
            wp_redirect("/custom-page/"); exit;
        }
    
        if( 123 == $args['form_id'] ){
            wp_redirect("/custom-page-2/"); exit;
        }
    }

    The above code will redirect the user to a specific page after registration is complete. Just change the URL and form IDs in the code to match your site.

    Regards,

    Thread Starter Paul

    (@pawelszroeder)

    Hi @champsupertramp , it redirects ok, but user is not automatically logged in after registration (like with default register). Is it possible?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @pawelszroeder

    Please try the updated code below:

    add_action( 'um_registration_complete', 'um_031122_redirect_after_registration', 10, 2 );
    function um_031122_redirect_after_registration( $user_id, $args ){
        
        if( 5 == $args['form_id'] ){
             UM()->user()->auto_login( $user_id );
    	 UM()->user()->generate_profile_slug( $user_id );
    
            wp_redirect("/custom-page/"); exit;
        }
    
        if( 123 == $args['form_id'] ){
             UM()->user()->auto_login( $user_id );
    	 UM()->user()->generate_profile_slug( $user_id );
    
            wp_redirect("/custom-page-2/"); exit;
        }
    }

    Regards,

    Thread Starter Paul

    (@pawelszroeder)

    It works perfect, thank you ??

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Thanks for letting us know. I’m marking this as resolved now.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirection after register from unique form’ is closed to new replies.