How to conditionally show some html text on frontend ONLY for paid prosites

Hi

I have an html footer in my subsites like "Powered By XYZ" that I want to show only if it is a free site. For paid prosites, I want to hide that html text.

How can I achieve this. Is there a php code that determines if a site s paid prosite ?

  • Adam Czajczyk

    Hello kka,

    I hope you're well today and thank you for your question!

    There's a function that you can use to check if a site is a Pro Site or a free (non-pro site) site: "is_pro_site()". Here's an example code:

    <?php
    
    function if_is_prosite_footer() {
    	if (function_exists('is_pro_site')) {
    		if (is_pro_site(get_current_blog_id())) {
    			$html = '<div class="prosite-footer"> YOUR FOOTER MESSAGE HERE </div>';
    			echo $html;
    		}
    	}
    }
    add_action('wp_footer','if_is_prosite_footer');

    This will print out "Your FOOTER MESSAGE HERE" text in site's footer if a site is a Pro Site (any Pro Site level) and do not do anything if either site is not a Pro Site (it's free) site or a Pro Site plugin is disabled.

    You will want however to add some custom CSS styles to make the message visible and well positioned on your site. To use this code follow these steps:

    - create an empty file with a .php extension (e.g. "my-pro-site-footer.php")
    - paste that code inside
    - upload the file to your sever via FTP, to the "/wp-content/mu-plugins" folder

    I hope that helps!
    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.