admin管理员组文章数量:1391991
I have a multiple author wordpress blog. I want to force redirected to login page, if any visitor view or access to specific pages. example : If user visit to specific page like, www.mysite/author-terms/, thereafter redirect to www.mysite/wp-admin.php/. Thanks in advance.
We have created a page in our blog called 'Instructions for Contributors'. If any visitor copied the link to this page ('Instructions for Contributors') and opens it directly in the browser. So it will open, and anyone can read the instructions given in it. Want to limit it to the blog's contributors. If a visitor tries to open the 'Instructions for Writers' page link directly, then it is redirected directly to the login page.
I have a multiple author wordpress blog. I want to force redirected to login page, if any visitor view or access to specific pages. example : If user visit to specific page like, www.mysite/author-terms/, thereafter redirect to www.mysite/wp-admin.php/. Thanks in advance.
We have created a page in our blog called 'Instructions for Contributors'. If any visitor copied the link to this page ('Instructions for Contributors') and opens it directly in the browser. So it will open, and anyone can read the instructions given in it. Want to limit it to the blog's contributors. If a visitor tries to open the 'Instructions for Writers' page link directly, then it is redirected directly to the login page.
Share Improve this question edited Mar 16, 2020 at 10:13 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Mar 16, 2020 at 6:08 Satya ComputersSatya Computers 11 bronze badge1 Answer
Reset to default 0You can check, if a user is logged in with is_user_logged_in()
and for certain page with is_page()
. If conditions are met, redirect the user with wp_redirect()
.
function redirect_non_loggedin_user() {
// if user is on certain page and not logged in
if ( ! is_user_logged_in() && is_page('instructions-for-contributors') ) {
// redirect to login page and back after login
wp_redirect( wp_login_url( get_permalink() ) );
exit;
}
}
add_action('template_redirect', 'redirect_non_loggedin_user');
本文标签: redirectHow can force redirected to login for two or more pages to view or access
版权声明:本文标题:redirect - How can force redirected to login for two or more pages to view or access 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744663902a2618414.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论