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?
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?
Try this: is_user_logged_in
function mypage_function() {
if( is_user_logged_in() ) {
get_template_part('mypage');
}else{
echo 'please login for awesomeness';
}
}
get_template_part
doesn't take a URL path as a parameter, it takes a php template file name, the/
is not needed. It will try to loadchildtheme/mypage.php
and thenparenttheme/mypage.php
if it doesn't exist – Tom J Nowell ♦ Commented Dec 3, 2018 at 21:48