Is_Pro_Site Usage - Coding help please

Hi

I am trying to output the current list of pro_sites a currently logged in user has (just like domain.com/pro-sites/ ) I will be adding it to a user dashboard.

Everytime I enter it, the code white screens my site....

<?php
if ( is_pro_site($blog_id) ) {
 $blogs = get_blogs_of_user(get_current_user_id());
	    if ($blogs) {
	      $content .= '<h3>' . __('Please choose a site to Upgrade or Modify:', 'psts') . '</h3>';
	      $content .= '
<ul>';
	      foreach ($blogs as $blog) {

	        //check for permission
	        switch_to_blog($blog->userblog_id);
	        $permission = current_user_can('edit_pages');
	        restore_current_blog();
	        if (!$permission)
	          continue;

	        $has_blog = true;

					$level = $this->get_level($blog->userblog_id);
					$level_label = ($level) ? $this->get_level_setting($level, 'name') : sprintf(__('Not %s', 'psts'), $this->get_setting('rebrand'));
					$upgrade_label = is_pro_site($blog->userblog_id) ? sprintf(__('Modify "%s"', 'psts'), $blog->blogname) : sprintf(__('Upgrade "%s"', 'psts'), $blog->blogname);

	        $content .= '
<li><a>checkout_url($blog->userblog_id) . '">' . $upgrade_label . '</a> (<em>' . $blog->siteurl . '</em>) - ' . $level_label . '</li>
';
	      }
	      $content .= '</ul>
';
	    }

	    //show message if no valid blogs
	    if (!$has_blog)
	      $content .= '<strong>' . __('Sorry, but it appears you are not an administrator for any sites.', 'psts') . '</strong>';

	  }

} endif; ?>

Cheers

Johnny

  • Aaron
    • CTO

    You have basic php errors, really should be doing this with debug on.

    <?php
     $blogs = get_blogs_of_user(get_current_user_id());
    	    if ($blogs) {
    	      $content .= '<h3>' . __('Please choose a site to Upgrade or Modify:', 'psts') . '</h3>';
    	      $content .= '
    <ul>';
    	      foreach ($blogs as $blog) {
    
    	        $has_blog = true;
    
    					$level = $this->get_level($blog->userblog_id);
    					$level_label = ($level) ? $this->get_level_setting($level, 'name') : sprintf(__('Not %s', 'psts'), $this->get_setting('rebrand'));
    					$upgrade_label = is_pro_site($blog->userblog_id) ? sprintf(__('Modify "%s"', 'psts'), $blog->blogname) : sprintf(__('Upgrade "%s"', 'psts'), $blog->blogname);
    
    	        $content .= '
    <li><a>checkout_url($blog->userblog_id) . '">' . $upgrade_label . '</a> (<em>' . $blog->siteurl . '</em>) - ' . $level_label . '</li>
    ';
    	      }
    	      $content .= '</ul>
    ';
    	    }
    
    	    //show message if no valid blogs
    	    if (!$has_blog)
    	      $content .= '<strong>' . __('Sorry, but it appears you are not an administrator for any sites.', 'psts') . '</strong>';
    
    	  }
    
    ?>

    Got rid of the permissions check as it's resource heavy and I assume you don't care what role they have in the list.

  • johnnymestizo
    • HummingBird

    Hi

    I have tried this, and it white screens...?

    <?php if ( is_user_logged_in() ) { global $user_ID, $current_user, $user_identity; get_currentuserinfo(); 
    
    // START PRO SHOPS CODE
    
     $blogs = get_blogs_of_user(get_current_user_id());
    	    if ($blogs) {
    	      $content .= '<h3>' . __('Please choose a site to Upgrade or Modify:', 'psts') . '</h3>';
    	      $content .= '
    <ul>';
    	      foreach ($blogs as $blog) {
    
    	        $has_blog = true;
    
    					$level = $this->get_level($blog->userblog_id);
    					$level_label = ($level) ? $this->get_level_setting($level, 'name') : sprintf(__('Not %s', 'psts'), $this->get_setting('rebrand'));
    					$upgrade_label = is_pro_site($blog->userblog_id) ? sprintf(__('Modify "%s"', 'psts'), $blog->blogname) : sprintf(__('Upgrade "%s"', 'psts'), $blog->blogname);
    
    	        $content .= '
    <li><a>checkout_url($blog->userblog_id) . '">' . $upgrade_label . '</a> (<em>' . $blog->siteurl . '</em>) - ' . $level_label . '</li>
    ';
    	      }
    	      $content .= '</ul>
    ';
    	    }
    
    	    //show message if no valid blogs
    	    if (!$has_blog)
    	      $content .= '<strong>' . __('Sorry, but it appears you are not an administrator for any sites.', 'psts') . '</strong>';
    
    	  }
    
    echo $content;
    
    // END PRO SHOPS CODE
    } else {} ?>
  • Aaron
    • CTO

    You really shoulb be doing coding in your own local development environment with debug on.

    <?php if ( is_user_logged_in() ) {
    	global $user_ID, $current_user, $user_identity; get_currentuserinfo(); 
    
    // START PRO SHOPS CODE
    
     $blogs = get_blogs_of_user(get_current_user_id());
    	    if ($blogs) {
    	      $content .= '<h3>' . __('Please choose a site to Upgrade or Modify:', 'psts') . '</h3>';
    	      $content .= '
    <ul>';
    	      foreach ($blogs as $blog) {
    
    	        $has_blog = true;
    
    					$level = $this->get_level($blog->userblog_id);
    					$level_label = ($level) ? $this->get_level_setting($level, 'name') : sprintf(__('Not %s', 'psts'), $this->get_setting('rebrand'));
    					$upgrade_label = is_pro_site($blog->userblog_id) ? sprintf(__('Modify "%s"', 'psts'), $blog->blogname) : sprintf(__('Upgrade "%s"', 'psts'), $blog->blogname);
    
    	        $content .= '
    <li><a>'.checkout_url($blog->userblog_id) . '">' . $upgrade_label . '</a> (<em>' . $blog->siteurl . '</em>) - ' . $level_label . '</li>
    ';
    	      }
    	      $content .= '</ul>
    ';
    	    }
    
    	    //show message if no valid blogs
    	    if (!$has_blog)
    	      $content .= '<strong>' . __('Sorry, but it appears you are not an administrator for any sites.', 'psts') . '</strong>';
    
    	  }
    
    echo $content;
    
    // END PRO SHOPS CODE
    } else {} ?>
  • Jason
    • The Incredible Code Injector

    Watch this, it will move you lightyears ahead in no time. Watch it carefully, bookmark it, refrence it, this is the best development stack I've ever seen, and the same one I use myself.

    http://css-tricks.com/video-screencasts/124-a-modern-web-designers-workflow/
    Local Dev starts at the 19min. mark. but I'd watch the whole video.

    For Windows & Wordpress install instant wordpress http://www.instantwp.com/

    And copy your website's files into the local folder in instant wordpress.

    https://speakerd.s3.amazonaws.com/presentations/87fa761026bf013092b722000a1d8877/slide_36.jpg?1374519521

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.