Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5527

Bhavesh Patel on "Import users from non-wordpress database"

$
0
0

Hi iamdanieljs,

You can create your own script to handle this task. Its very simple task though.

You have to create custom database connection for fetching data from eventbooking_clients table
Create one array namely users to get users data from eventbooking_clients table.
Close this database connection after getting all the users in array.

//For Example

foreach($users as $user){
   $user_id = username_exists( $user['user_name'] );
   if ( !$user_id and email_exists($user['mail']) == false ) {
      $random_password = wp_generate_password( $length=12,
                         $include_standard_special_chars=false );
      $user_id = wp_create_user($user['user_name'], $random_password,  $user['email']);
  } else {
    $random_password = __('User already exists.  Password inherited.');
  }
}

If you want to do this task on regular basis(Example:execute a script on daily basis) than you can create one Cron job for it.
Also you can manage this by inserting one new column like last_updated date in eventbooking_clients table and fetch only required users.


Viewing all articles
Browse latest Browse all 5527

Trending Articles