skip to Main Content

I have created a registration form using Elementor Page Builder. Now, I want to redirect the user to a different page if he/she is trying to access that registration page after logging in.

Is there any Elementor hook available for that? I know the WordPress function called is_user_logged_in().

2

Answers


  1. function my_logged_in_redirect() {
         
        if ( is_user_logged_in() && is_page( 12 ) ) 
        {
            wp_redirect( get_permalink( 32 ) );
            die;
        }
         
    }
    add_action( 'template_redirect', 'my_logged_in_redirect' );
    

    You should get the ids of the page where the form is and the id of the page you want to redirect the user to.

    Code goes in your child theme functions.php file

    Reference: here

    Login or Signup to reply.
  2. The ‘Content Area Not Found’ error might appear on Elementor designed sites when you use that snippet and try to edit page of ID 12 (in your example) in certain cases.

    To avoid this, add the following code before the if-statement of your snippet:

    if ( ElementorPlugin::$instance->preview->is_preview_mode() ) {
            return;
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search