Show Alert Message in Admin if domain mapping field is blank

Hi,

Anyway to show a message in the admin panel if the domain mapping field is blank?

Something like an alert that shows at the very top that says something like, "Wait! You forgot to map a domain to your blog, click here to be taken to the settings page"

Thanks!

  • Andre Foisy

    Hi there @cnolan90,

    Welcome to the WPMU Dev community, and thank you for contacting our support team with your question.

    I hope you're having a great day! :slight_smile:

    Interesting question and certainly something could be eventually done, but may I ask in what this "alert message" would be useful for you? I mean, if one doesn't map a domain name to one's blog, obviously it will be easy to find out that one cannot access that blog through his/her domain name, no? :wink:

    Something to think about, let me know what you have in mind please.

    Best regards,
    Andre

  • cnolan90

    Thanks for your response.

    I posed the question in a simple manner hoping it would be easier to get a response and then I was going to modify the code myself from there.

    In the grand scheme I am hoping to only show an alert message if the mapped domain is a subdomain. I was hoping to just get some direction in what plugin file I could place the alteration in, and how I could assign the mapped domain from the wp_domain_mapping table to a variable.

    I was just trying to make the question easier and possibly more universal so maybe other people could use this resource and modify it to their needs.

    Let me know if you think this is something you guys could address.

    Thanks!

  • cnolan90

    As an updated to help anybody else, this custom plugin I wrote seems to do the trick for my final solution of showing a message to users who are using a subdomain. You would just replace the yourprimarydomain.com and obviously the alert message. Maybe I have a future in plugin development :wink:

    <?php
    /*
    Plugin Name: Custom Upgrade Alert
    */
    global $wpdb;
    $blog_id = get_current_blog_id();
    $mapdomain = $wpdb->get_var("SELECT domain FROM wp_domain_mapping WHERE blog_id = $blog_id");
    if (strpos($mapdomain,'yourprimarydomain.com') !== false) {
    	function addDashboardAlert() { ?>
    	<script type="text/javascript">
    	$j = jQuery;
    	$j().ready(function(){
    		$j('.wrap > h2').parent().prev().after('<div class="update-nag">This is the alert .</div>');
    	});
    	</script>
    	<?php } add_action('admin_head','addDashboardAlert');
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.