Unable to create user in Discourse from WP with new registration form

So I did exactly what you told me to do.

add_action( 'cred_save_data', 'cred_autologin_V3', 10, 3 );
    
function cred_autologin( $post_id, $form_data ){
  if ( ID1 == $form_data['id']  ) { // Edit as required
    wp_set_current_user( $post_id );
    wp_set_auth_cookie( $post_id );
   do_action( 'wp_login' );

//    wp_redirect( home_url( '/some-ending-page/' ) );
  //  exit(); 
  }
}

But I get the following error:
Message: Uncaught ArgumentCountError: Too few arguments to function WPDiscourse\WordPressEmailVerification\WordPressEmailVerification::verify_email_after_login(), 1 passed in /home/customer/www/domain.com/public_html/wp-includes/class-wp-hook.php on line 307 and exactly 2 expected in /home/customer/www/domain.com/public_html/wp-content/plugins/wp-discourse/lib/wordpress-email-verification.php:128

I have another code that bypasses email verification

add_filter( 'discourse_email_verification', 'disable_discourse_email_verification_prowess');
function disable_discourse_email_verification_prowess() {
  wp_mail( 'himanshu@eshowprowess.com', 'User verified', 'Status must change' ); 
   
    return false;
}

Is this a code sequencing issue or do I need to pass some parameter to the wp_login action?

Edit: The user was created in WP and was logged in but the user was not created in Discourse.

1 Like