Create WP user from custom post type with action hook

I have a custom post type that I would like to use to create a WP user with an action hook. Once a user has completed the form the hook should enter the basic information to begin registering a wp user i.e. username, password email.

This is the function I have so far but I don’t know why it is not working.

function agency_add_tenant( $post_id) {
    $username = get_post_meta ( $post_id, 'username', true );
    $password = get_post_meta ( $post_id, 'password', true );
    $email_address = get_post_meta ( $post_id, 'email', true );

    $user_id = function wp_create_user( $username, $password, $email_address );

    // Email the user
    wp_mail( $email_address, 'Welcome!', 'Your Password: ' . $password );
}

Related posts