Example #1
0
function sp_my_classes_shortcode($atts, $content = null, $code = "")
{
    ob_start();
    global $current_user;
    //classes I teach
    $teacher = new SPTeacher($current_user->ID);
    $teacher->getClassesForTeacher();
    if (!empty($teacher->classes)) {
        ?>
			<div class="column one_half">
				<h2 class="page-title">Classes I Teach</h2>
				<?php 
        $teacher = new SPTeacher($current_user->ID);
        $teacher->getClassesForTeacher();
        if (!empty($teacher->classes)) {
            foreach ($teacher->classes as $teacher->singleclass) {
                global $post;
                $post = $teacher->singleclass;
                setup_postdata($post);
                get_template_part('loop', 'class');
            }
        }
        ?>
			</div>
			<div class="column one_half last">
				<h2 class="page-title">Classes I'm In</h2>
		<?php 
    }
    //classes I'm In
    $student = new SPStudent($current_user->ID);
    $student->getClassesForStudent();
    if (!empty($student->classes)) {
        foreach ($student->classes as $student->singleclass) {
            global $post;
            $post = $student->singleclass;
            setup_postdata($post);
            get_template_part('loop', 'class');
        }
    } else {
        ?>
			<div class="pmpro_message pmpro_alert">You are not a member of any classes yet. <a href="<?php 
        echo home_url();
        ?>
">Why not join some</a>?</div>
		<?php 
    }
    ?>
		
		<?php 
    if (!empty($teacher->classes)) {
        ?>
</div><?php 
    }
    ?>
		
		<div class="clear"></div>
		<?php 
    $temp_content = ob_get_contents();
    ob_end_clean();
    return $temp_content;
}
 static function pmpro_confirmation_message($message)
 {
     /*
     	need getClassesForStudent to get classes across sites to do this
     */
     global $current_user;
     $student = new SPStudent($current_user->ID);
     $sites = $student->getSchools();
     if (!empty($sites)) {
         if (count($sites) > 1) {
             $new = "\n<p>You are already enrolled in classes for some schools at SchoolPress:</p>";
         } else {
             $new = "\n<p>You are already enrolled in classes for a school at SchoolPress:</p>";
         }
         $new .= "\n<ul>";
         foreach ($sites as $site) {
             $new .= "\n<li><a href='" . get_site_url($site->blog_id, "/my-classes/") . "'>" . $site->blogname . "</a></li>";
         }
         $new .= "\n</ul>";
         $message = str_replace("Below are details", $new . "Below are details", $message);
     }
     return $message;
 }