I want to be notified each time a user change the site


I want to be notified each time a user change the site domain by using the domain mapping plugin.

In my hosting, I have to manually insert the domain of each new site into my main domain. I do not know how to avoid it. If there is a better (automatic) solution I will be happy :slight_smile:

So, how to custom the domain mapping to receive an email comprising each new domain?

Thank you very much.

  • Vaughan
    • Support/SLS MockingJay

    Hi @andreza,

    There is no automatic way, changing the domain would always require the user to setup an A record for his domain or have you park that domain on your server.

    I'm not sure if there's a hook for sending out a notification when the domain is changed. I've looked but couldn't find it. I will ask one of our developers to see if there's a quick way of doing it.

    However, you could restrict access to the Tools > domain mapping menu page, so that users can't change the domain without asking you?

    You can use a plugin such as Advanced access manager to do that.


    Hope this helps

  • Jose
    • Bruno Diaz

    Hey there @Andreza,

    Hope you are doing great today :slight_smile:

    You can send a notification for each time a new domain is added by hooking into the 'domainmapping_added_domain' action.

    I coded this in a form of a must use plugin, so you just need to download the attached file and place it into the folder
    (create the folder if it doesn't exists).

    For reference, this is the code. This is a very simple email, you can improve it by changing the text, setting the content type to html, etc.

    if(! class_exists('Custom_Code') ):
        class Custom_Code{
            private $blog_template_id = 0;
            private $additional_tables = array();
            function __construct(){
                add_action( 'domainmapping_added_domain', array($this, 'domain_added_notification' ) );
            function domain_added_notification($domain, $blog_id ){
                $admin_email = get_site_option( 'admin_email' );
                $message = sprintf('The domain %s was added for the blog ID %s', $domain, $blog_id);
                wp_mail( $admin_email, 'New Domain Added', 'The message' );
        new Custom_Code;

    Please let us know if this works for you.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.