I have written a code for inserting wordpress user if I try to add new user I am getting 3 warning errors saying like below:
"Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/intecom/public_html/app/wp-includes/wp-db.php on line 1129 " ,
"Warning: Illegal offset type in isset or empty in /home/intecom/public_html/app/wp-includes/cache.php on line 725"
"Warning: array_key_exists(): The first argument should be either a string or an integer in /home/intecom/public_html/app/wp-includes/cache.php on line 725".
my code is below:
$first_name = 'my_firstname_value'; $last_name = 'my_lastname_value'; $trainer_email = 'email@example.com'; $course_registered = Array (  => 2410 ); $pro_icon_status = '1'; $this->institute_icon = '1'; $this->institute_name = 'my_institute_name'; $user_data = array( 'user_login' => $first_name, 'user_pass' => '', 'user_email' => $trainer_email, 'first_name' => $first_name, 'last_name' => $last_name, 'role' => 'trainer' ); $random_password = wp_generate_password(8,false); $user_id = wp_insert_user( $user_data ); update_user_meta( $user_id, 'course_registered',$course_registered ); update_user_meta( $user_id, 'inistitute_name',$this->institute_name ); update_user_meta( $user_id, 'inistitute_icon',$this->institute_icon ); update_user_meta( $user_id, 'trainer_icon',$pro_icon_status ); wp_set_password($random_password, $user_id);
My input is only either string (or) array but why it is saying that "Iam passing object" I don't know what is happening. It is driving me nuts. can any one please tell me what was my mistake? Thanks in advance.
Update: The problem is not with 'wp_insert_user' or 'update_user_meta', actual problem is with the data that I was giving i.e. Am giving the same user_login name which is already there in the database, I am getting the WP_Error Object as below:
WP_Error Object ( [errors] => Array ( [existing_user_login] => Array (  => Sorry, that username already exists! ) ) [error_data] => Array ( ) )
Now can u plz tell me how to show that error to user on the front end?