php - Adding a user in wordpress with wp_insert_user doesn't work -


i'm trying programmaticaly insert user in wordpress using form input account details. code looks this:

$userdata = array(     'user_login'  =>  $_post["post_email"],     'first_name'    =>  $_post["post_voornaam"],     'last_name'    =>  $_post["post_achternaam"],     'user_email'   =>  $_post["post_email"],     'user_pass'   =>  $_post["password_confirm"] );  $user_id = wp_insert_user( $userdata ) ;  add_user_meta( $user_id, 'klant_id', $klant_id ); 

as see i'm using user meta field after create account. sadly none of works. have idea why failing?

it doesn't seem return errors either.

make sure of post values. var_dump($_post). if have of post values,then try get_error_message() function errors messages while inserting user.

$userdata = array(     'user_login'  =>  $_post["post_email"],     'first_name'    =>  $_post["post_voornaam"],     'last_name'    =>  $_post["post_achternaam"],     'user_email'   =>  $_post["post_email"],     'user_pass'   =>  $_post["password_confirm"] );  $user_id = wp_insert_user( $userdata ) ;   if( is_wp_error( $user_id  ) ) {     echo $return->get_error_message(); }  add_user_meta( $user_id, 'klant_id', $klant_id ); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -