I’m not doing any WordPress development at the moment, so I can’t test your code. I think the issue is here:
$result = DiscourseUtilities::add_user_to_discourse_group($user_id, $s2member_level_1_groups);
If I’m reading the logs correctly, that call is returning:
[error_data] => Array
(
[wpdc_response_error] => Array
(
[http_code] => 404
[http_body] => {"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}
)
I’m guessing that the problem is that there isn’t a group with the name "Member" on your Discourse site.
I’m not sure what you are doing here, but I don’t think it’s related to the error:
// Additional SSO parameters if needed
$sso_params = array();
$sso_params = apply_filters('wpdc_sso_params', $sso_params, $user_data);