<?php
//Author: Sarah Vardy
//Date: 14-03-2007
//This snippet displays the posts made by the user who is currently logged in.
# set page to redirect to if user is not logged in, site_start by default
if(!isset($_SESSION['webInternalKey']) || empty($_SESSION['webInternalKey'])) {
$logout = isset($logout) ? $logout : $modx->config['site_start'];
$modx->sendRedirect($modx->makeUrl($logout));
}
//Get user login name and store it in variable userLogin
$userLogin = $modx->getLoginUserID();
//Find the correct entries in the database that correspond to posts made by this user
//Select the modx table where the posts are stored
$tbl = $modx->getFullTableName('site_content');
$result = $modx->db->select("*", $tbl);
$count = 0;
$post_count = array();
while($row = $modx->db->getRow($result)) {
//if createdby id matches the userLogin id then display this row
if ($row["createdby"] == -($userLogin))
{
echo " <br />";
//display this post
$post_array[$count] = $row["'pagetitle'"];
//return $result;
echo "Post " . $count . " " . $post_array;
$count ++;
echo " <br /> ";
}
}
//return $count;
//return $post_array;
//return count($post_array);
//$tempUserPosts = $modx->db->select("*", $tbl, "pagetitle, longtitle, pub_date ", "pub_date DESC", "10");
//$tempUserPosts = $modx->db->select("*", $tbl, "createdby=".$userLogin, "pub_date DESC", "10");
//return $tempUserPosts;
?>return $modx->getLoginUserID();