Login to Wordpress from another website
I have a Simple PHP Website at www.example.com
and I have a wordpress blog at www.example.com/blog/
and both of them have user login pages. I wo开发者_运维百科uld like the user to logged into the wordpress blog as well when the user logs in using www.example.com
login.
Please help
The proper way of doing it is
- Create a wordpress plugin
- Use the plugin to listen for the wordpress engine initiation
- On initiation check for the user session in the browser or in your external application
- If a user session is found (assuming your usernames and emails are unique for both systems, so that a single registration is allowed with it) check for a wordpress user with matching username or email
- If a wpuser is found, set the current user as that
- If no user is found create a new wordpress user and set him as the current user
There are neat API's available for doing this in wordpress. We have used it to integrate wordpress with many external websites, CMS and Social networking sites like Elgg.
You should have a look at the bbPress Integration plugin that does the same thing to integrate WordPress and BBPress forums.
Basically you will simply need to create some cookies on the user browser crypted with the appropriate secret keys.
精彩评论