Configuring automatic domain syncing with cPanel

Since version 1.6.2, network admins hosting their network over a cPanel install no longer need to manually add mapped domains to the Add-on Domains panel. This tutorial will go over the necessary steps to configure this integration on your WP Ultimo network install.

Adding the config to your wp-config.php file

You’ll need to edit your wp-config.php file to include the custom configuration constants WP Ultimo needs to correctly connect to the cPanel 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:

IMPORTANT: Some hosts will say your cPanel URL is yourdomain.com/cpanel. They do that for your convenience, but that URL is just a redirect to the real cPanel URL (which is usually something like yourdomain.com:2083). If that’s the case, put only yourdomain.com as the WU_CPANEL_HOST value. The number after the “:” is the port (yourdomain.com:2083). If in your case that number is different from 2083, you’ll need to pass that as well using the WU_CPANEL_PORT config.

After replacing the values, you should have something like this:

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 cPanel’s Add-on Domains page automatically.

The same is true for domain removals. Every time a domain is deleted from the network, that change will be communicated to your cPanel account instantly!

Important: Changing the root directory of the add-on domain

This is not the case for the majority of cPanel installs, but if for any reason your network is not located on the /public_html directory of your install, you need to let WP Ultimo know about that, otherwise the add-on domains will be added pointing to the wrong place.

To do that, simply add the following definition below the other ones you have added before, changing  the /public_html value with to the directory where your network is located (ex.: “/my_sub_dir_where_the_network_is“).

Troubleshooting

If for any reason the domains are not being automatically added to your cPanel after this setup, head to WP Ultimo > System Info > Logs and search for the cpanel.log file (not the cpanel-cookie.log). Errors like wrong credentials, access denied get saved to that file when they happen.

Was this article helpful?

Related Articles

5 Comments

  1. Max

    Add the following lines to your wp-config.php file, right above the /* That’s all, stop editing! Happy blogging. */ line.

    I’d prefer to put these credentials in a file above webroot and then include in wp-config…
    eg. in wp-config there would be like:
    // DATABASE AND OTHER SECRETS
    if ( file_exists( ‘/home/path/configs/config.php’ ) ) {
    include( ‘/home/path/configs/config.php’ );
    }
    …I do something like this with creds and other sensitive stuff for a little extra security 🙂
    Cheers, Max

  2. jfoc

    I don’t think its safe solution for domain sync, especially when you put the cpanel credentials. would be good if using cpanel REST

    1. Arindo Duque

      Hi, @jfoc. The wp-config.php shouldn’t be accessible directly (it exits on that case), but if you are concern about security, you can adopt something like the suggested by Max in the previous comment. We already use the CPanel RESTApi, but unfortunately we can only use version 2 as that is the only one with endpoints to add-on domains. Kind regards.

  3. sunshine

    hello do we need to do this setting in latest version as on today, or do we not?
    confused by the remark “Since version 1.6.2, network admins hosting their network over a cPanel install no longer need to manually add mapped domains to the Add-on Domains panel.”

    1. Arindo Duque

      Hi, there. You need to do it if you want this to be automatic. Before 1.6.2, no integration was available and users would need to add all mapped domains manually. That’s what that phrase was saying, but maybe we can come with another formulation to make that clear. Thanks for the report =)

Leave A Comment?