API Reference


This method registers a new user or updates an existing user if it already exists and returns the user's ID.

The userData is optional, and can be used to update user information if needed. The "userName" parameter will be used as the primary key here. The username may not be updated through this service call; it will only be used if a new user is being registered.

The "userName" parameter must only contain letters (a-z), digits (0-9), underscore (_), hyphen (-), period (.), and the "at" sign (@).

This method returns the user id of the existing user, or the newly created one.

Optional fields for userData are provided below.


int users.registerOrUpdate ( int vhost, string userName, array userData = array(), mixed returnUserInfo = false )


NameTypeRequiredDefault valueDescription
vhostintRequirednoneThe id of the vhost.
userNamestringRequirednoneThe username for the user. This is used to determine if a user already exists.
userDataarrayOptionalarray()An array with user information. Only user and email are required, other possible key / value pairs are listed below.

userData Array

The different fields available to you within the array. Please note not all of them need to be defined.

NameTypeRequiredDefault ValueDescription
userSTRINGRequirednoneUsername for the account. The user parameter must only contain letters (a-z or A-Z), digits (0-9), underscore (_), hyphen (-), period (.), and the "at" sign (@).
emailSTRINGRequirednoneEmail address for the account holder. This has to be a properly formatted email address.
firstnameSTRINGOptionalnoneFirstname for the account holder
lastnameSTRINGOptionalnoneLastname for the account holder
passwordSTRINGOptionalrandom stringPassword for the account holder (if none is provided the system will generate one and send it to the user)
address1STRINGOptionalnoneThe account holders address.
address2STRINGOptionalnoneA second line for the account holders address.
citySTRINGOptionalnoneThe account holders city.
languageSTRINGOptionalnoneThe language the account holder is using.
stateSTRINGOptionalnoneThe account holders state/province.
countrySTRINGOptionalnoneThe account holders country.
postalSTRINGOptionalnoneThe account holders zip or postal code.
birthdateSTRINGOptionalnoneThe account holders birth date.
cellphoneSTRINGOptionalnoneThe account holders cell phone.
phoneSTRINGOptionalnoneThe account holders phone number.
websiteSTRINGOptionalnoneThe account holders website.
accounttypeSTRINGOptional0The account type for the account holder.
occupationSTRINGOptionalnoneThe account holders occupation.
newsletterBOOLEANOptional0Whether the account holder wants to receive a newsletter.
genderCHAROptionalnoneThe account holders gender, acceptable values are M or F.
metaSTRINGOptionalnoneAny meta data you wish to store about the account holder.
external_idSTRINGOptionalnoneThe id provided by a 3rd party external authorization system.
NB: This is to be used with 'external_id_provider'.
external_id_providerINTEGEROptionalnoneThe integer that represents the 3rd party that provided the external id.
Possible values are:
  • 1 (Facebook)
  • 4 (Janrain)
  • 5 (Gigya)
  • 6 (Stripe)
  • 7 (Google)
  • 8 (Apple)
  • 9 (Twitter)
  • 10 (Instagram)
  • 11 (YouTube)

NOTE: The external_id_provider is required if external_id is passed.

Sample Response

Sample REST Response
<?xml version="1.0" encoding="UTF-8"?>
Sample JSON Response
    "status": true,
    "result": NEW/UPDATED_USER_ID

Code examples


Be the first to comment on registerOrUpdate.

Add a Comment

  • captcha