0

I am developing a page in WordPress. In functions.php file I have this:

function feed_add_notmusa() {
  add_feed('mypage', 'mypage_function');
}

function mypage_function() {
  get_template_part('/mypage');
}

But how can I restrict access to /mypage so only logged in users can access?

Could you please help me?

fuxia
  • 107,219
  • 39
  • 255
  • 462
skycomputer2
  • 103
  • 3

1 Answers1

1

Try this: is_user_logged_in

function mypage_function() {
  if( is_user_logged_in() ) {
    get_template_part('mypage');
  }else{
    echo 'please login for awesomeness';
  }
}
admcfajn
  • 1,326
  • 2
  • 13
  • 30