• Resolved epokk

    (@epokk)


    Hello,
    I use the plugin and find it very good.

    However, I have a quick question about a feature.

    Is it possible to redirect a person who does not have the rights to access a page, to another page of the website instead of displaying an error message?

    Thank you for your reply !

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @epokk

    We don’t support redirection for content permission feature, but you can use this code snippet and modify it to fit your needs:

    add_action( 'template_redirect', function() {
      // Redirect users from specific page 
      // when user doesn't have particular role 
      $user = wp_get_current_user();
      if ( is_page('contact') && ( ! is_user_logged_in() || ( ! empty($user) && in_array( 'author', (array) $user->roles ) ) ) ) {
        $redirect = 'https://your-domain.com/unauthorized'; // Change this to the correct URL
        wp_redirect( $redirect );
        exit;
      }
    } );

    Hopefully, that helps.

    Thread Starter epokk

    (@epokk)

    Great thanks a lot !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirect to another page’ is closed to new replies.