I am using the commenting system to all users to add a private note that only they can see to posts and I am using the wordpress comments system to do it. I wrote a function to call the logged in user comments in a shortcode to display on their profile page. I can get this to work without passing it through a variable but it always shows up at the top of the page. I can't seem to call these variables inside the function. All I get is a blank page. Please take a look and tell me what I am doing wrong.
function notes_by_comments() {
global $wpdb;
$current_user = wp_get_current_user();
$note_content = '<h5 style="border-bottom: 1px solid #DADADA; padding-bottom: 7px;padding-top: 25px;"><strong>Notes</strong></h5>';
$commentQuery = "SELECT * from $wpdb->comments WHERE user_id=$current_user->ID ORDER BY comment_date DESC LIMIT 0 ,5";
$comments = $wpdb->get_results($commentQuery);
foreach ($comments as $comment) {
$note_content. = '<li><b>Note for</b> <a href="'. get_permalink($comment- >comment_post_ID). '#comment-'.$comment->comment_ID .'">';
$note_content. = get_the_title($comment->comment_post_ID) . '</a> -';
if(get_post_type( $comment->comment_post_ID ) === 'for_sale_listings'){
$note_content. = "<b>Sale Listing</b>";
} elseif (get_post_type( $comment->comment_post_ID ) === 'rental_listings'){
$note_content. = "<b>Rental Listing</b>";
} elseif (get_post_type( $comment->comment_post_ID ) === 'roomate_share'){
$note_content. = "<b>Roommate Share</b>";
}
$note_content. = '<p>' . $comment->comment_content . '</p></li>';
return $note_content;
}
}
add_shortcode('notes', 'notes_by_comments');