user - Custom usermeta fields, registration page and login widget wordpress -
here's situation: have old site, old userdatabase (mysql). i'd migrate these users wordpress without losing old data (recipe id's, custom user fields etc.).
besides i'd make custom registration page (extra) user data allready had on old site.
i tried find plugins (wp-members, registration widget, register plus redux, etc.), didn't fit purpose.
i'm starting think need code myself, make wordpress unable update.
does have solution problem?
thx, rick
should easy although may have assign users new password. ok users long know it's coming.
take old database , simple sql query extract data, use code following create new user each user in old database:
$newuser = array( 'user_pass' => wp_generate_password( 12,0 ), 'user_login' => $email, 'user_nicename' => $name['first'].' '.$name['last'], 'user_email' => $email, 'display_name' => $name['first'].' '.$name['last'], 'nickname' => $name['first'].' '.$name['last'], 'first_name' => $name['first'], 'last_name' => $name['last'], //'' ); $user_id = wp_insert_user($newuser); wp_new_user_notification($user_id, $newuser['user_pass']); this code works of wordpress 3.1. in example you'd want replace $name variables data you've provided old database.
the last 2 lines important because that's real work happens. wp_insert_user function create user (or throw error if you're missing info) , wp_new_user_notification function send them email password. highly recommend taking time rewrite new user notification plugin (it's pluggable function can copy paste functions.php , make changes there) email users makes sense. write own email function or if passwords stored in plain text pass info on wp.
edit: missed need custom fields, gravity forms quite can add custom field user update_user_meta function. in sample code above you'd want add after like:
update_user_meta($user_id, "my_custom_data_key", "my_custom_data_value"); to retrieve data display, you'd use get_user_meta:
print get_user_meta($user_id, "my_custom_data_key");
Comments
Post a Comment