最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - prevent anonymous access to Wordpress site (non-admin site)

programmeradmin1浏览0评论

I'm using WP to build a help/training portal for a commercial software product (Product X). We'd like to restrict access to this new WP site to only authenticated users of Product X as it contains sensitive information. Integrating with Product X's auth API is not a problem (I've done this before). However, all the docs/examples related to customizing WP auth seem focused on the WP admin portal, not the actual WP site. Is such a thing supported? If so, links to examples/docs would be appreciated.

I'm using WP to build a help/training portal for a commercial software product (Product X). We'd like to restrict access to this new WP site to only authenticated users of Product X as it contains sensitive information. Integrating with Product X's auth API is not a problem (I've done this before). However, all the docs/examples related to customizing WP auth seem focused on the WP admin portal, not the actual WP site. Is such a thing supported? If so, links to examples/docs would be appreciated.

Share Improve this question edited Apr 30, 2020 at 15:59 Mitch A asked Apr 30, 2020 at 15:43 Mitch AMitch A 1011 bronze badge 3
  • 3 It's possible to redirect all non-logged in users to the login page. Then you restrict who can/can not register for the site, so I assume you'd use Product X's API to authenticate/create accounts. I guess you'd have to build some sort of single sign-on utility, so they'd sign in to Product X's site and then be auto-logged in via WordPress? – Tony Djukic Commented Apr 30, 2020 at 16:11
  • This is a basic method: peterstavrou/blog/website/… Also take a look at: codex.wordpress/Function_Reference/auth_redirect See Yahya's answer to this question: wordpress.stackexchange/questions/131879/… – Tony Djukic Commented Apr 30, 2020 at 16:16
  • Does this answer your question? How to redirect non-logged in users to a specific page? – cjbj Commented Apr 30, 2020 at 16:43
Add a comment  | 

1 Answer 1

Reset to default 0

Add this to the top of your header.php file, or a file that will be loaded at the top of every page.

<?php
if(!is_user_logged_in()) {
    wp_redirect('/wp-login.php');
    exit;
}
?>

Someone will probably point out a reason why not to do this, but it's the first thing that came to mind.

发布评论

评论列表(0)

  1. 暂无评论