I’ve built a directory of members on a non-WP site (using php and mysql). Each member can log in and update their details using a username and password.
I want to be able to get this to automatically create a user on the WordPress site using the details from the directory of members. Ideally, if they update their details on the directory of members the their user details on the WP site will update. I am not sure how this would work in terms of passwords. Both the WP and directory of members sites are on the same server and so can access each database.
I’d also be able to have a link on the Directory of members that will take them to the WP site automatically logging them in. I’m not sure about this last point, particularly due to security, however I just want to avoid them having to re-enter their username and password.
Is there a way to achieve the above, ideally using something that already exists?
If you can write the non-wp site to work with the users and usermeta table then you can use wordpress to create and verify the login cookies. If this is not an option, you can do something along the lines of checking for the login information from the other site in wordpress and if it exists and is in the proper format, use
wp_signon()
to create the wordpress login cookie.So you’re asking for, basically, two things.
A common way of doing this is building an authentication service on top of your non-WP site which the WordPress will use. The non-WP site will return a login token to the WP site. Store that token in a cookie.
An example use case would be:
HTH