[insert_php]

//Switch to the Member’s site which holds all of the subscription data:
switch_to_blog(‘2’);
remove_filter(‘the_content’, ‘wpautop’); //Remove stupid fucking auto p addition:

//Determine the user memberships:
$userID = get_current_user_id();

//Get each membership package as we go:
$afl = wc_memberships_is_user_active_member($userID, ‘afl-betting-tips’);
$nrl = wc_memberships_is_user_active_member($userID, ‘nrl-best-bets’);
$greyhound = wc_memberships_is_user_active_member($userID, ‘greyhound-guru’);
$bestBets = wc_memberships_is_user_active_member($userID, ‘best-bets’);
$ratingsMelbourne = wc_memberships_is_user_active_member($userID, ‘ratings-melbourne’);
$ratingsNSW = wc_memberships_is_user_active_member($userID, ‘ratings-nsw’);
$ratingsSA = wc_memberships_is_user_active_member($userID, ‘ratings-sa’);
$trialSpy = wc_memberships_is_user_active_member($userID, ‘trial-spy’);
$snowysBets = wc_memberships_is_user_active_member($userID, ‘snowys-bets’);
$hilow = wc_memberships_is_user_active_member($userID, ‘hi-lo’);
$laysBetfair = wc_memberships_is_user_active_member($userID, ‘lays-betfair’);
$mattsSportsBets = wc_memberships_is_user_active_member($userID, ‘matts-sports-bets’);
$soccerAdvisor = wc_memberships_is_user_active_member($userID, ‘soccer-advisor’);

//Add package category ID to an array:
$allPackages = array(); //Holds all packages:

//Create a temporary array for holding the packages:
$tempArray = array(
“categoryId” => NULL,
“packageName” => NULL
);

if ($afl) {
$tempArray[“categoryId”] = 75;
$tempArray[“packageName”] = “AFL – Tips”;
array_push($allPackages, $tempArray);
}
if ($nrl) {
$tempArray[“categoryId”] = 76;
$tempArray[“packageName”] = “NRL – Best Bets”;
array_push($allPackages, $tempArray);
}
if ($greyhound) {
$tempArray[“categoryId”] = 68;
$tempArray[“packageName”] = “Greyhound Guru”;
array_push($allPackages, $tempArray);
}
if ($bestBets) {
$tempArray[“categoryId”] = 71;
$tempArray[“packageName”] = “Tips – Best Bets”;
array_push($allPackages, $tempArray);
}
if ($ratingsMelbourne) {
$tempArray[“categoryId”] = 70;
$tempArray[“packageName”] = “Ratings – Melbourne”;
array_push($allPackages, $tempArray);
}
if ($ratingsNSW) {
$tempArray[“categoryId”] = 79;
$tempArray[“packageName”] = “Ratings – NSW”;
array_push($allPackages, $tempArray);
}
if ($ratingsSA) {
$tempArray[“categoryId”] = 96;
$tempArray[“packageName”] = “Ratings – SA”;
array_push($allPackages, $tempArray);
}
if ($trialSpy) {
$tempArray[“categoryId”] = 66;
$tempArray[“packageName”] = “Trial Spy”;
array_push($allPackages, $tempArray);
}
if ($snowysBets) {
$tempArray[“categoryId”] = 74;
$tempArray[“packageName”] = “Snowy’s Bets”;
array_push($allPackages, $tempArray);
}
if ($hilow) {
$tempArray[“categoryId”] = 73;
$tempArray[“packageName”] = “High-Low”;
array_push($allPackages, $tempArray);
}
if ($laysBetfair) {
$tempArray[“categoryId”] = 81;
$tempArray[“packageName”] = “Lays – Betfair”;
array_push($allPackages, $tempArray);
}
if ($mattsSportsBets) {
$tempArray[“categoryId”] = 77;
$tempArray[“packageName”] = “Matt’s Sports Bets”;
array_push($allPackages, $tempArray);
}
if ($soccerAdvisor) {
$tempArray[“categoryId”] = 78;
$tempArray[“packageName”] = “Soccer Advisor”;
array_push($allPackages, $tempArray);
}

//Determine whether the user has a membership of some kind by using the size of the array:
$totalMemberships = count($allPackages);

if ($totalMemberships > 0) { //User has memberships, output them all:

$html = “”;

//Echo the header of the table:
$html = $html . ‘

Premium Package Tips & Ratings

    • ‘;

//Cycle through all of the packages:
foreach ($allPackages as $key => $thePackage) {

//If it’s the first spot, output the active tab li:
if ($key == 0)
$html = $html . ‘

  • ‘;
    else //Else, just output the normal li element:
    $html = $html . ‘
  • ‘;//Run through the category and pull out the tabs:
    $html = $html . ‘

    ‘ . $thePackage[“packageName”] . ‘

    ‘;
    //Echo out the main title:

    //Run through the category and pull out the latest posts from that section:
    $args = array(
    ‘posts_per_page’ => 10,
    ‘offset’ => 0,
    ‘category’ => $thePackage[“categoryId”]
    );
    $allPosts = get_posts($args);

    //Print the first thing of the content:
    $html = $html . ‘

    ‘;

    foreach ($allPosts as $thePost) {

    $postID = $thePost->ID;
    $permaLink = get_permalink($postID);
    $postContent = ‘

    ‘ . $thePost->post_content . ‘

    ‘;
    $postTitle = $thePost->post_title;
    $postLength = strlen($thePost->post_content);

    //If post is too long, cut it at 150 characters
    /*if($postLength > 150) {
    $postContent = $postContent . ‘Read More‘;
    }*/

    //Echo out the tip title and the content:
    $html = $html . ‘

    ‘ . $postContent . ‘

    ‘;

    //var_dump($thePost);

    }

    //Reset the post data for looping around again:
    wp_reset_postdata();

    //Close the content and li for the next tab:
    $html = $html . ‘

  • ‘;
    }

    //Close the tabbed area:
    $html = $html . ‘

‘;

}

echo $html;
[/insert_php]