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

Unless something has changed, you need to use the approach that is outlined here: Map custom User Fields - #7 by simon.

First, make sure the custom fields already exist on Discourse. Then, on your Discourse site’s /admin/customize/user_fields page, add .json to the URL so that you can see the userfield’s JSON. For example http://localhost:4200/admin/customize/user_fields.json.

Use the id values from the JSON to set SSO keys that that look like this: custom.user_field_<field_id>. For example custom.user_field_1

I can’t test this right now. Let me know if this works. If it hasn’t already been done, it should get documented in its own topic.