• Resolved dgcov

    (@dgcov)


    I can’t see what I’m doing wrong.

    `
    $email=’[email protected]’;
    $pass=wp_generate_password ( 12, false );
    $user_id = wp_insert_user(
    array(
    ‘user_login’ => $email,
    ‘user_pass’ => $pass,
    ‘first_name’ => $form->data[‘first_name’],
    ‘last_name’ => $form->data[‘last_name’],
    ‘user_email’ => $email,
    ‘display_name’ => $form->data[‘first_name’] . ‘ ‘ . $form->data[‘last_name’],
    ‘nickname’ => $form->data[‘first_name’] . ‘ ‘ . $form->data[‘last_name’],
    ‘role’ => ‘contributor’
    )
    );

Viewing 2 replies - 1 through 2 (of 2 total)
  • What is the $form class? I don’t see that defined anywhere.

    Before these lines of code, I would add this to debug it:

    die(print_r(array(
    'user_login' => $email,
    'user_pass' => $pass,
    'first_name' => $form->data['first_name'],
    'last_name' => $form->data['last_name'],
    'user_email' => $email,
    'display_name' => $form->data['first_name'] . ' ' . $form->data['last_name'],
    'nickname' => $form->data['first_name'] . ' ' . $form->data['last_name'],
    'role' => 'contributor'
    )));

    It’s important to see exactly what is being passed to the wp_insert_user() function.

    Thread Starter dgcov

    (@dgcov)

    Sorry, it’s a derivative of the plugin I’m using: Chronoforms.

    But, yes, you’ve cracked it: thanks very much!

    The wp_insert_user() function was in a separate function and it didn’t have the $form->data scope in it’s namespace.

    Thanks again!

    Dunno how that got past me. :blush:

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Empty_user_login on wp_insert_user’ is closed to new replies.