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
1 Answer
Reset to default 0Add 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.