The add_user_to_discourse_groups
function will create a Discourse user if it doesn’t already exist. If that function is being called for your users, then you should be fine. Where you might run into problems will be for existing WordPress users who got their membership before the code was added to your site. If that is the case, you will probably need to add the users to Discourse groups through the SSO parameters that are passed to Discourse on login.
To pass additional SSO parameters with the WP Discourse plugin, you can hook into the 'wpdc_sso_params'
filter. The parameter you need to use to add users to a Discourse group is called add_groups
. You can use it with something like this:
add_filter( 'wpdc_sso_params', 'wpdc_custom_sso_params', 10, 2 );
function wpdc_custom_sso_params( $params, $user ) {
if ( /* some condition that returns true if groups should be added for the user */ ) {
$params['add_groups'] = 'comma,separated,group,names'; // Don't use spaces between names.
}
return $params;
}