wp_create_user example


function create_user($username$password$email) {
    _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' );
    return wp_create_user($username$password$email);
}

/** * Unused function. * * @deprecated 2.5.0 */
function gzip_compression() {
    _deprecated_function( __FUNCTION__, '2.5.0' );
    return false;
}


    $errors = apply_filters( 'registration_errors', $errors$sanitized_user_login$user_email );

    if ( $errors->has_errors() ) {
        return $errors;
    }

    $user_pass = wp_generate_password( 12, false );
    $user_id   = wp_create_user( $sanitized_user_login$user_pass$user_email );
    if ( ! $user_id || is_wp_error( $user_id ) ) {
        $errors->add(
            'registerfail',
            sprintf(
                /* translators: %s: Admin email address. */
                __( '<strong>Error:</strong> Could not register you&hellip; please contact the <a href="mailto:%s">site admin</a>!' ),
                get_option( 'admin_email' )
            )
        );
        return $errors;
    }

    

        $user_id        = username_exists( $user_name );
        $user_password  = trim( $user_password );
        $email_password = false;
        $user_created   = false;

        if ( ! $user_id && empty( $user_password ) ) {
            $user_password = wp_generate_password( 12, false );
            $message       = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
            $user_id       = wp_create_user( $user_name$user_password$user_email );
            update_user_meta( $user_id, 'default_password_nag', true );
            $email_password = true;
            $user_created   = true;
        } elseif ( ! $user_id ) {
            // Password has been provided.             $message      = '<em>' . __( 'Your chosen password.' ) . '</em>';
            $user_id      = wp_create_user( $user_name$user_password$user_email );
            $user_created = true;
        } else {
            $message = __( 'User already exists. Password inherited.' );
        }

        

function wpmu_create_user( $user_name$password$email ) {
    $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );

    $user_id = wp_create_user( $user_name$password$email );
    if ( is_wp_error( $user_id ) ) {
        return false;
    }

    // Newly created users have no roles or caps until they are added to a blog.     delete_user_option( $user_id, 'capabilities' );
    delete_user_option( $user_id, 'user_level' );

    /** * Fires immediately after a new user is created. * * @since MU (3.0.0) * * @param int $user_id User ID. */
Home | Imprint | This part of the site doesn't use cookies.