Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

So you're asking for, basically, two things.

  1. authentication from an external application (the non-WP site)
  2. single sign on (logging in to your non-WP site also logs them in to your WordPress site).

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:

  1. User lands on your WP site. He attempts to login.
  2. WP sends those credentials to the non-WP site for authentication. Upon success, the non-WP site returns a token. The token means that the credentials were valid.
  3. Add the token to a cookie or a session.
  4. Send user to a logged in page on your WP site.

HTH

share|improve this answer
    
OK, so basically you are talking about bypassing the WP login and using the external site for authentication. Wouldn't this mean the WP site wouldn't have any users in it's database? I was hoping to have users on WP and sync them with an external site. Does that make sense? –  baritoneuk Jan 13 '12 at 19:21
    
@baritoneuk - It makes sense. In general, you would want a single authoritative source for your users. If you're choosing WP then the non-WP site would need to authenticate against the WP DB. If your authoritative source is the non-WP site the you would need to do what I described in my answer. either way, you're by passing the login mechanism in one of the sites. –  rexposadas Jan 15 '12 at 3:48
add comment

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.

share|improve this answer
    
Not entirely sure I follow you. I need the non-WP to be able to create and edit users on the WP site. –  baritoneuk Jan 13 '12 at 17:30
    
There is a host of functions provided by wordpress which do just that. wp_create_user() and update_user_meta() would be good to look at, the signon is really gonna be the only tricky part imo. –  m0r7if3r Jan 13 '12 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.