0

I have wordpress site and a project management system from codecanyon. Here is the link

I have disabled registration for users in project managment system, only login is enabled. I need to make users manually from the admin panel. I only allow users to register through wordpress. For registration purposes I am using woocommerce registration page that comes with the plugin.

Now I need to create a function in wordpress using woocommerce or without using woocommerce, so that when a user register on wordpress, it will automatically create an account on my project management database. So when a user login to wordpress, the user is also loggged in to the project management without entering login information again. Here is the fields on users table of project management.

  • id (auto increment),
  • username,
  • password,
  • email,

user level(can be set within function)

I can create a custom registration page for wordpress if needed. I've searched a lot, but found nothing like this. I only find the methods to use external login on wordpress, but nothing on how to create wordpress users on external db. Any suggestions would be appreciated.

  • Doing something like this is a multi-step process in WP. The main problem is having access to the user's WP password to pass to an external system (note probably security issue). The second issue is creating the user in an external system, typically you would use the other system's APIs to create users. – user42826 Dec 24 '13 at 16:28
1

No matter how you create a new user, it will end up calling wp_insert_user, which runs the action user_register right before finishing. So you can do something like the following:

add_action('user_register','register_user_remotely');

function register_user_remotely($user_id) {
   //add user to external database
   $url = ...; //url of file that will receive the $user->data in the $_POST variable
   $user = get_user_by('id', $user_id);
   if (!is_wp_error($user)) {
      $response = wp_remote_post($url,array('body' => $user->data));
      if (is_wp_error($response)) {
         ...
      } else { ... }
   }
}

This will post all user data from the wp_users table to the project management app. As pointed out by user42826, you'll then have to use its API to create the user at that end.

$user->data['user_pass'] contains the user's encrypted password, but this is useless unless the app encrypts its password just as Wordpress. Seeing the front end of your app, probably the best option is to create an arbitrary password in the app and make it send a mail to the user with a password reset link.

Your Answer

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

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