Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WordPress MU Domain Mapping CN

Map any blog on a WordPress MU website to an external domain. WordPress MU Domain Mapping Simplified Chinese Language

Action Hooks

You can now hook into certain parts of the domain_mapping mu-plugin to enable you to extend the features that are built in without the need to modify this plugin. To do this, just create a script within the mu-plugins dir that is called AFTER this plugin (eg, call it domain_mapping_extended.php).

  • dm_echo_updated_msg

This hook is for when you want to add extra messages for your end users when they update their settings, the current usage would be to remove the existing action and replace it with your own as shown within the example further down the page.

  • dm_handle_actions_init

Before we add our own handlers for our users wanting to update their mappings, we can use this action to maybe connect to your datacenter API ready for communication. An example would be to load an API class and connect before we send and recieve XML queries. Once again, see the example down the page. Your function can make use of the $domain variable.

  • dm_handle_actions_add

When an user adds a domain name to their mappings, this action can be used to perform other tasks on your server. An example would be to check the user has already set up the DNS records for the name to correctly point to your server. Your function can make use of the $domain variable.

  • dm_handle_actions_primary

This may or may not be commonly used in most cases but is there just in case. Your function can make use of the $domain variable.

  • dm_handle_actions_del

When an user deletes one of their domain mappings, this action can be used to reverse what dm_handle_actions_add has done. An example would be to remove the domain mapping from your server using your datacenter's API. Your function can make use of the $domain variable.

  • dm_delete_blog_domain_mappings

If the blog is ever deleted and you make use of handle_actions, then this action will enable you to tidy up. An example would be when an user has set up multiple domain mappings and the blog is deleted, your function can remove any mess left behind. Your function can make use of the $domains array (numbered array of domains). NOTE, this will also be called if the user has no mappings, care should be taken in the case of an empty array.


<?php // Filename: mu-plugins/domain_mapping_extended.php

// NOTE,
//  This example will not 'just work' for anyone, it is to show basic
//  usage of dm_echo_updated_msg, dm_handle_actions_init and
//  dm_handle_actions_add

// We do not need translations but would really like a message when a
// users DNS entry is not ready

function dm_echo_extended_updated_msg() {
    switch( $_GET[ 'updated' ] ) {
        case "add":
            $msg = 'You have added a new domain name.';
        case "exists":
            $msg = 'That domain name already exists, please try again.';
        case "primary":
            $msg = 'New primary domain created - enjoy!';
        case "del":
            $msg = 'The domain name has been removed.';
        case "dnslookup":
            $msg = 'The domain is not pointing to ' .
            get_site_option( 'dm_cname' ) . ', please set up your DNS.';
    echo "<div class='updated fade'><p>$msg</p></div>";

// Prepare to use our Datacenter API

function dm_extended_handle_actions_init($domain) {
    global $datacenter_api;
    // There is a good chance we will be accessing the datacentre API
    require_once(dirname(__FILE__) ."/classes/xmlAbstract.class.php");
    require_once(dirname(__FILE__) ."/classes/xmlParserClass.php");
    require_once(dirname(__FILE__) ."/classes/datacenterAPIClass.php");
    $datacenter_api = new datacenter_api('MY_API_KEY', 'API_TYPE');
$datacenter_api = null;
add_action('dm_handle_actions_init', 'dm_extended_handle_actions_init');

// Check the users DNS is ready to go (we are using the CNAME option)
// then add the mapping to the datacenter API

function dm_extended_handle_actions_add($domain) {
    global $datacenter_api;
    // Check the domain has the correct CNAME/ANAME record
    $dmip = gethostbyname(get_site_option( 'dm_cname' ));
    $urip = gethostbyname($domain);
    if ($dmip != $urip) {
        wp_redirect( '?page=domainmapping&updated=dnslookup' );
add_action('dm_handle_actions_add', 'dm_extended_handle_actions_add');

Requires: 2.8.6 or higher
Compatible up to: 2.9.2
Last Updated: 2010-2-24
Active Installs: Less than 10


0 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.