I have the below code working except for one thing: I am trying to display some conditional content at the bottom if the current user is the author of the stories that are returned. Currently for some reason, the content in the IF statement is displayed no matter what. I know that $user_ID is working correctly (it shows correct current user in a var_dump) and I also know that the results code is getting the correct author displayed for the correct author on the page when I echo $results[0]->display_name.
This means that something is faulty in this statement:
if ($user_ID = $results[0]->stories.ID)
I also tried it with just ID (instead of stories.ID which did not work either.
<?php
global $wpdb;
$user_ID = get_current_user_id();
$results = $wpdb->get_results("
SELECT wp_users.ID, wp_users.display_name,
stories.ID, stories.SID, stories.story_name, stories.category,
writing.ID, writing.text, writing.approved
FROM stories
JOIN wp_users ON stories.ID = wp_users.ID
JOIN writing ON stories.SID = writing.SID
WHERE (stories.SID = $the_SID) AND (writing.approved = 'Y')");
<?php
if ($user_ID = $results[0]->stories.ID){
echo "author level permission buttons here";
}
The equality check operator in
==
.=
is the assignment operator: