Configuring automatic domain syncing with Cloudways
IMPORTANT NOTE: This article is only for WP Ultimo version 1.x users
NOTE: If you are on Cloudways and are getting an error 502 or a “user already exists” during the signup flow, be sure to read this article for a fix.
Since version 1.6.0, network admins hosting their network over Cloudways no longer need to manually add mapped domains to the additional domain list on the Cloudways control panel. This tutorial will go over the necessary steps to configure this integration on your WP Ultimo network install.
IMPORTANT: In order to use Domain Mapping, you must have only one App per Server!
Step 1: Getting a Cloudways API Key
Follow the steps 1 and 2 of the official Cloudways tutorial to obtain an API key for your account (Read the tutorial). Copy the API Key as we will need it in the following steps.
Step 2: Get the Server ID
The next piece of information we will need is the server ID of the server hosting your WordPress install on Cloudways. To discover the server ID, visit the Server Management screen of the server. The server ID will be present on the URL of that page after the “/server/” portion of it.
The URL takes the form of https://platform.cloudways.com/server/SERVER_ID_HERE/access_detail
Step 3: Get the App ID
We’ll need to do a similar thing to obtain the App ID for your WordPress installation. Go to Application Management screen of your WordPress app and the App ID will be present on the URL, after the “/apps/” portion of it.
The same thing happens here: the URL takes the form of https://platform.cloudways.com/apps/YOUR_APP_ID_HERE/access_detail
Step 4: Adding the config to your wp-config.php file
Now, you’ll need to edit your wp-config.php file to include the custom configuration constants WP Ultimo needs to correctly connect to the Cloudways API.
Add the following lines to your wp-config.php file, right above the /* That’s all, stop editing! Happy blogging. */ line. Replace the contents with the information obtained in the prior steps:
<code>/* WP Ultimo: Adding automatically domain syncing with Cloudways */<br>define('WU_CLOUDWAYS', true); // Tells WP Ultimo we should connect to Cloudways<br>define('WU_CLOUDWAYS_EMAIL', 'email@example.com'); // The email address you use to login on Cloudways<br>define('WU_CLOUDWAYS_API_KEY', 'api_key_here'); // API Key obtained on step 1<br>define('WU_CLOUDWAYS_SERVER_ID', 'server_id_here'); // Server ID obtained on step 2<br>define('WU_CLOUDWAYS_APP_ID', 'app_id_here'); // App ID obtained on step 3<br>/* end WP Ultimo */
Since 1.6.1 – Additional Step – Extra Domains
The Cloudways API is a bit strange in that it doesn’t offer a way to add or remove just one domain, only a way to update the whole domain list. That means that WP Ultimo will replace all domains you might have there with the list of mapped domains of the network every time a new domain is added.
If there are domains you want to keep on the list, use the WU_CLOUDWAYS_EXTRA_DOMAINS as demonstrated below, with a comma-separated list of the domains you wanna keep (this is useful if you need a wildcard setting, for example, that needs to be on that list at all times).
Here’s how it should look on your wp-config.php (fake values used below):
You’re all set!
Now, every time a new domain is mapped in the network (via the Aliases tab by the network admin or via the custom domain meta-box on the user’s Account page) will be added to the Cloudways platform automatically.
The same is true for domain removals. Every time a domain is deleted from the network, that change will be communicated to your Cloudways account instantly!