• Hello, sorry if this is not in the correct tpoic tried to post it here https://wordpress.org/support/topic-tag/rest-api but couldn’t for some reason.

    I’m looking for a way to create a user from my node app. So far I’ve identified 3 possible ways to do this :
    1. Using the wp-rest api , tried a request like so as described in the documentation
    https://developer.wordpress.org/rest-api/reference/users/#create-a-user passing an object for the meta.

    {
        "username" : "test2",
        "email": "test2@gmail.com",
        "password": "123456",
        "meta": {
            "messengerId": "11223344"
        }
    
    }

    which failed to create my custom messengerId in wp_usersmeta table.

    2. Using a node wrapper for the wp-cli command
    However couldn’t identify a way to create a user and meta at the same time. There’s a command to create a user and a command to add meta knowing the id which I wouldn’t know before creating the said user. Need to do both at the same time or store the id from the first command. Not sure how to do this.

    3. Most dangerous option. Using node-mysql manually creating the user in the wp_users and wp_usermeta keeping in mind the way wordpress does it when creating the new user and the fields required.

    Can anyone chime in on this? Ideally would like to do this using the REST api.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘REST API – Create user with custom meta’ is closed to new replies.