0

I have WP installed in the root of my website.

In the same directory there’s a completely independent application.

What I want to do is the following:

when the user accesses the page containing the application:

  1. if he is in NOT logged into WP, the application must redirect him to the traditional wp-login page;
  2. if he IS logged into WP, he can use the application;

Is there any way to get/read WP user data from an independent PHP page?

If not, can you suggest different solutions to avoid users having to authenticate multiple times on the same website (once for the CMS, once for the application)?

Any help is appreciated.

0

You can access to any WordPress functions if you first include the wp-load.php to your custom PHP page.

<?php
require_once('path/to/wp-load.php');

if( ! is_user_logged_in() ) {
  auth_redirect();
}

// Your application starts from here...

?>
  • So now your application is not "independent" anymore, and you're loading the entire WP bootstrap for a single function. – Michael Sep 19 '18 at 13:33
  • @Michael: this is not a problem in my case – user140189 Nov 11 '18 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy