Use wordpress login on another site

Asked

Viewed 478 times

0

Today I have a site made in Joomla, where the user logs in, and if he is in a certain group, can access a restricted area, php site developed internally. This site is in a directory on the same joomla server.

I intend to migrate to Wordpress, and look for a plugin, or other way to maintain this mechanism of permission to the site developed by the company, using the access control of wordpress itself.

  • Only logged in users can access the restricted area;
  • The appearance of the restricted area does not need to be the same as the wordpress site;
  • Do you want to use the WP access control on this other site that is in joomla? If that’s what I think this plugin can work JSON API Auth I confess that I never had to do this, so I do not know exactly if this plugin solves everything.

  • No... what I need is that the site made in php, which is an administrative panel, is accessible only to users who have logged in wordpress. Joomla’s gonna get out of here.

  • Even so I think that this plugin I passed seems to be a good way out, why Voce will need among other things the "role" of the user in WP on your site, to display the correct content of the right panel? Apparently this JSON API Auth will give you this information.

  • I will test both options. And add the results here.

1 answer

0


There is a filter login_redirect is used to change the redirected location after logging in. This could be the location defined by the "redirect_to" parameter sent to the login page. There on your pages you could use a redirect function if you haven’t logged in. This example redirects administrators to the dashboard and other users to the home page.

<?php auth_redirect(); ?>

Example

Require a user to log in in order to view a restricted page with is_user_logged_in:

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

Take a look at Function Reference/auth redirect.

  • It even works, but the tricky thing will be him calling the function is_user_logged_in() that only exists in WP within the panel that it already has. It works very well within a plugin or WP theme.

  • But then you can use require_once to impose the function files of your plugin, Good Tips?

  • I will test both options. And add the results here.

  • @Celsomarigojr managed to solve his problem?

  • @Cleidimarviana need to test better. I had to add some plugins in order to add links to an external project. The dashboard directory is on the same level as the wordpress root. I believe I can make the necessary Imports. As soon as I test everything put the results and validate the answer.

  • @Celsomarigojr Good luck!

  • @Cleidimarviana the way you posted solves the problem, you can put more information on how to do. Like, which directory is more correct for me to put the PHP website folder in. Or another alternative using a plugin, like Advanced Access Manager for example.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.