We use our Wordpress instance as SSO provider for Discourse. After user registered Wordpress account he confirm his email address. But when he trying to log in to Discourse he asked by Discourse to confirm his email again. Is there any way to avoid email confirmation by Discourse?
How is the user confirming their email address? Are you using the default WordPress registration page, or a front-end registration page?
We are using front-end (custom) registration page. Is there any difference?
Yes, WordPress doesn’t require email addresses to be verified, but it’s important for Discourse that the email address is verified (that it belongs to the user who has registered.) The WP Discourse plugin hooks into the WordPress registration process and verifies that the email sent by wp_new_user_notification
was responded to. It’s not possible for the plugin to do this with custom registration systems, so if one of those systems is being used, it forces Discourse to verify the email address.
If you know that your user’s email address are verified, you can add a function that hooks into the discourse_email_verification
filter. It passes two parameters: $require_activation
and $user_id
Something like this will work. Be careful about this though. The conditional in the function should be dependent on something that happens in your registration process that lets you know the email address has been verified.
add_filter( 'discourse_email_verification', 'wpdc_custom_discourse_email_verification', 10, 2 );
function wpdc_custom_discourse_email_verification( $require_activation, $user_id ) {
if (/* some condition */) {
$require_activation = false;
}
return $require_activation;
}