I am attempting to make a POST request via API to create a new user.
Use case: Creating a new user once a credit card form is submitted on a Wordpress site. Ultimately, this will be fired from Google Tag Manager using Javascript.
To test this, I have written the following, saved it as a PHP file, and uploaded the file to my server. I get an error of Parse error: syntax error, unexpected 'POST' (T_STRING) in /nas/content/live/username/newuser.php on line 2
Apologies if I look like someone who knows what he’s doing! I appreciate your help, @Arkshine and will continue looking for how to solve this.
This is absolutely a task I am under-prepared for, yet I am trying.
I was able to get the request to save by putting Api-Username and Api-Key inside quotes. Thank you Arkshine. I then executed the script via GTM then check my Discourse logs without anything to show.
I think you misunderstood the API. This endpoint is not to create an user. It will generate an invite link and send it to the user’s email. Once clicked, the user will be able to register.
To create manually an user, It should be this endpoint: Discourse API Docs
I recommend that you take a step or two back to describe the problem you’re trying to solve. It’s not clear that the path you’re taking is a good solution.
Why not use sso and one of several WordPress subscription managers that are documented here? How to update group membership from WordPress is well documented.
Alright, I’m struggling to find the right approach. I want to keep my forum on discourse for all the benefits AND I want to provide a simple course with 7 modules dripped over 14 weeks.
With your Feverbee Theme Component, the layout looks great.
Previously, I ran the course in cohorts and just had folks pay, then I would manually create their Discourse user. That was fine, but now I want a more “open enrollment.”
I looked into Paid Membership Pro but don’t love the idea of using a Wordpress site just to manage the membership.
I used Memberful for a few months, but their 4.9% transaction fee plus monthly fee is a bit extreme.
Discourse Subscriptions looks good, though I believe I’m not able to show the Plan pages to folks who are not logged in (which they wouldn’t be, if they were not already customers).
My idea to do an API POST to create a new member and add them to a Group is a fine tie-over fix while I drive more members. Once I have more members, I thought I could have some custom coding done.
Bonus issue: I have an iOS app I compiled from the repo and would prefer not renting a virtual machine again to re-compile with a new URL if I have to use SSO from a WP site. I might be wrong on having to change the app config file; I haven’t done this yet.
Wordpress SSO + Paid Membership Pro seems like the only option for actual member management.
That seems like a solvable problem, perhaps by paying for the functionality or perhaps by having part of your site that’s accessible to people who haven’t yet paid.
I’ve played with the Subscriptions plugin a bit today. I think that what I’d recommend is that you have some free content on your site so that people have a reason to create an account before purchasing a course. I think this is a pretty decent solution to making the plan pages available to non-subscribers. It makes sense that they’d want to see a bit of the content before paying.
My thought is that just getting this API POST to work will give me a short-term solution while I on-board customers and can afford custom development.
My Google Tag Manager tag is firing, though nothing is showing inside Discourse. If I can get GTM to create a new user and set the correct Group, my solution is 70% long-term, and 100% short-term.
I tried this URL in Postman: https://site.co/users.json?Api-Key=12345&Api-Username=system&email=hello@domain.com&group_names=Alumni&custom_message=Welcome321
Which gave me back this:
{
"success": true,
"active": false,
"message": "<p>You’re almost done! We sent an activation mail to <b>hello@domain.com</b>. Please follow the instructions in the mail to activate your account.</p><p>If it doesn’t arrive, check your spam folder.</p>"
}
However I have received no email. I’ve checked my logs at /logs and nothing is listed. Checked Spam, too.