Now it all makes sense. Thanks, Angus.
I have the “Create or Sync Discourse Users on Login” setting checked. The user is not getting created in Discourse because some users register on WP but do not visit the community on first login. They might come back and login and then click on community URL and then the user is created.
The current auto login after registration on WP does not use WP_login
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 );
// wp_redirect( home_url( '/some-ending-page/' ) );
// exit();
}
}
I would prefer to create the user in Discourse on WP registration.
I have custom hooks on the user registration form that can run the API. Is there a code I can add to the custom hook to create a user in Discourse via the API?
This is the part I don’t know how to do i.e. trigger wp_login from a custom hook.