Show a Subsite's Pro Sites Level with Php?

Hi guys,
Wondering if it's at all possible to use some kinda php code to display a Site's Pro Sites Level (free, 1, 2,3 etc)
I want to put this into a dashboard widget.
Cheers guys :slight_smile:

  • aristath
    • Recruit

    Hello there @Casey, I hope you're well today!

    Wondering if it's at all possible to use some kinda php code to display a Site's Pro Sites Level (free, 1, 2,3 etc)

    Sure it's possible!

    Here's some sample code:

    <?php
    
    global $wpdb;
    $blog_id = $wpdb->blogid;
    $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
    $level = $wpdb->get_var( $sql );
    
    if ( $level == 1 ) {
    	echo 'Level 1 content here';
    }
    
    if ( $level == 2 ) {
    	echo 'Level 2 content here';
    }
    
    if ( $level == 3 ) {
    	echo 'Level 3 content here';
    }
    
    if ( $level == 4 ) {
    	echo 'Level 4 content here';
    }

    I hope that helps!

    Cheers,
    Ari.

  • aristath
    • Recruit

    Works a treat!

    :slight_smile: I'm glad I could help!

    Would it be possible to display the level if the user is on a 'Free' Account?

    Well... you could perhaps check if the site is NOT on a premium level by adding something like this:

    if ( $level != 1 && $level != 2 && $level != 3 && $level != 4 )
    	echo 'Level is not 1, 2, 3 or 4.';
    }

    Cheers,
    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.