Title: wp_insert_user($udata) raises PHP warning in wp-admin/menu-header.php ?!
Last modified: August 21, 2016

---

# wp_insert_user($udata) raises PHP warning in wp-admin/menu-header.php ?!

 *  [erikstainsby](https://wordpress.org/support/users/erikstainsby/)
 * (@erikstainsby)
 * [13 years ago](https://wordpress.org/support/topic/wp_insert_userudata-raises-php-warning-in-wp-adminmenu-headerphp/)
 * The following code both 1) triggers a PHP warning in menu-header.php (which seems
   whacked out to me), and 2) fails to insert the new user record as desired:
 *     ```
       $userdata = array(
       	'user_login'=> $_POST['username'],
       	'nickname' => $_POST['nick'],
       	'user_email'=> $_POST['email'],
       	'user_pass' => $_POST['password'],
       	'role'		=> 'author'
           );
           if( email_exists($userdata['user_email']) == false && username_exists($userdata['user_login'])== false )
           {
       	error_log( "name & email do not already exist" );
       	// do the creation deed
       	$user_id =  wp_insert_user($userdata);
           }
       ```
   
 * What I can’t figure out is why the devil this code is triggering wp-admin/menu-
   header.php at all ?
 * (Note: the usual security precautions have been stripped away during debugging;
   I do know how to sanitized user input.)

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years ago](https://wordpress.org/support/topic/wp_insert_userudata-raises-php-warning-in-wp-adminmenu-headerphp/#post-3731046)
 * There’s nothing wrong with the code in isolation. I placed it on a test page 
   and it worked as expected without any warnings. I did however hardcode values
   in place of $_POST parameters just because I didn’t feel like creating a form.
   Shouldn’t make a difference.
 * Perhaps some unfortunate interaction with your theme or a plugin?

Viewing 1 replies (of 1 total)

The topic ‘wp_insert_user($udata) raises PHP warning in wp-admin/menu-header.php?!’
is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/wp_insert_userudata-raises-php-warning-in-wp-adminmenu-headerphp/#post-3731046)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
