i’ve a wordpress website and i want to restric 2 page to registered users only. I don’t want to add another plugin, since i can’t code, i’ve found online this piece of code, how can i add more then one page?

add_action( 'template_redirect', 'redirect_to_specific_page' );

function redirect_to_specific_page() {

if ( is_page('gift') && ! is_user_logged_in() ) {

wp_redirect( 'http://website.com/login', 301 ); 

Read more here: Website pages visible only to registered users


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: