I cannot add user to the discouse forum from a wordpress website when user added in a membership

From visiting your site, I think your WordPress site is functioning as the DiscourseConnect authentication provider for your Discourse site. If that is correct, you can use the add_user_to_discourse_group helper function to add WordPress users to Discourse groups: wp-discourse/lib/utilities.php at main · discourse/wp-discourse · GitHub. Details about using the function are here:

Note the use statement at the top of the code example:

use WPDiscourse\Utilities\Utilities as DiscourseUtilities;

And how that is then used to call the (static) function:

$result = DiscourseUtilities::add_user_to_discourse_group( $user_id, $group_name );