Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Brian Layman

    (@brianlayman)

    Unfortunately, I don’t think that’s possible. Interesting question though…

    Hi guys!
    I’ve made a small function that may help redirecting when the user tries to access a passworded page directly. Just put this in your functions.php file:

    function my_page_template_redirect()
    {
        if ( post_password_required($post) ) {
            wp_redirect( home_url('/parent-page-slug/') );
            exit();
        }
    }
    add_action( 'template_redirect', 'my_page_template_redirect' );

    tested and working. Hope it helps!

    Plugin Author Brian Layman

    (@brianlayman)

    Thanks Estaban,
    Unfortunately that isn’t generic enough for the plugin code, but it will work in the functions.php for a custom theme.

    The difficulty for the plugin is that it has to work with people having multiple parent pages AND also having passworded pages that are not at all related to this plugin. Right now the only way I think I could write a generic routine is to look for the parent of the passworded post and see if the content of that parent uses a smartpwpages short code. And that’s not very efficient.

    I’ll think on it more, but for now, thanks for the suggestion!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘redirect when users try to access pw pages directly’ is closed to new replies.