Simple Membership Plugin › Forums › Simple Membership Plugin › create user with API
- This topic has 3 replies, 2 voices, and was last updated 1 year ago by
admin.
-
AuthorPosts
-
May 15, 2025 at 4:13 am #30400
gipsea
ParticipantDear all,
I’m new with the use of API. I tried query and login action successfully but I continue to receive error message.
This is the request:
[2025-05-14T17:52:48.082Z] Registration Request Successful Request URL: https://myurl/wp-json/?key=mykey&swpm_api_action=create&username=USER&email=EMAIL&password=PWD&first_name=NAME&last_name=LASTNAME&membership_level=2 Data Sent: { "username": "USER", "email": "EMAIL", "password": "PWD", "first_name": "NAME", "last_name": "LASTNAME", "membership_level": "2" } Response: { "success": false, "message": "Missing one of the mandatory fields: first_name, last_name, email. Ensure that you are using HTTP POST method to send the data.", "requestUrl": "https://myurl/wp-json/?key=mykey&swpm_api_action=create&username=USER&email=EMAIL&password=PWD&first_name=NAME&last_name=LASTNAME&membership_level=2", "data": { "result": "failure", "message": "Missing one of the mandatory fields: first_name, last_name, email. Ensure that you are using HTTP POST method to send the data." } }This is the log msg as I created. I’m using POST and the fields seams correct to me but still getting the message. Is there a log from the server side or within the plugin that I can check?
Thanks
May 15, 2025 at 4:19 am #30402admin
KeymasterThe query parameters may be getting stripped by a security or firewall plugin on your site. It’s worth checking if that’s the case. Enable the debug log feature to view the full list of parameters received by the API addon on the server side.
Note: The request should be sent to your site’s homepage URL. The
examplesfolder included in the addon contains sample code you can test with. Start with the basic example to verify it’s working, then build on it as needed.May 16, 2025 at 4:49 pm #30414gipsea
Participant@admin thanks for your reply.
at the end I revised the code, enabled CORS and finally I moved 2 steps forward but one step backward ahahah
At the moment, the remote form is able to create a new user but only in the simple membership members without syncing with the WP users nor it seams it triggers to send the activation email. Also as side error, in the SM members, the username is shown as [incomplete]
checking the API documentation I understood I only have to define a create query.
Am I doing anything wrong? Have I missed any piece of information?
thanks again
May 17, 2025 at 7:09 am #30415admin
KeymasterIt’s likely that the username and password values are not being included in your API request. Without these details, the system cannot create the corresponding WordPress user account.
To investigate further, edit the following file from the API addon:
swpm-api/classes/class.swpm-api-profile-endpoints.phpSearch for the following line of code in this file:
SwpmUtils::create_wp_user( $wp_user_info );Add some debug code before or after this line to confirm whether your API call is reaching this point.
-
AuthorPosts
- You must be logged in to reply to this topic.