• 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

    (@bcworkz)

    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.