Support » Fixing WordPress » Restrict a page to logged on users

  • Resolved talytabnel


    How can I restrict a page to users (logged on). I don’t see the need for a plugin, as that’s all I need to do.
    I also do not want to use the rules as I’ve edited those for the CMS (editor).
    Short Code?
    Any help is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,
    You can try with below code to restrict a page to a logged in user.

    if ((is_user_logged_in()) && is_page('Goals')){
    	wp_redirect( home_url() );

    You can also add below condition to the above code
    current_user_can( 'edit_user', $user_id )

    Thanks for that.
    I thought it was out there somewhere but couldn’t find it or remember where!

    Thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.