i have got the folowing code.
$coauthors = get_post_meta( $post_id, "coAuthors" );
print_r($coauthors);
ok result from print_r is
Array ( [0] => 78 ) Array ( [0] => 78 )
now my user id is 78 so it should return true with the follow code but it doesnt.
$key = array_search( 78, $coauthors );
if($key) {
return true;
}else{
echo "no";
}
Why do i always get no where am i going wrong what the best way to do this???
Thanks
Im still getting issues here is my function.
add_action('is_true','isdAuthorTrue');
function isdAuthorTrue( $post_id ) {
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$current_user = wp_get_current_user();
$coauthors = get_post_meta( $post_id, "coAuthors" );
$key = array_search( $current_user->ID, $coauthors );
$key = 0;
if($key !== false) {
return true;
} else {
return false;
}
}
and then i am trying to run this in the loop.
if(do_action( 'is_true', $post->ID )){
echo "yes";
}else{
echo "no";
}
help???
That results in false.
You should check for key like this: