I have 2 post types, one is for my posts and the other one is used as a submission form.
When a user is on a single post page for post type A, I am trying to do several checks to then display content -
1) I'm checking if the user is logged in
2) if he has published any posts (submitted forms) in post type B
3) If so is custom field (1) in authors published posts in post type B empty or not
4) If its not empty, does the value match the value of custom field (2) of any posts in post type A that is currently being viewed
This is what I have so far ---
<?php
$user = wp_get_current_user();
$user_id = get_current_user_id();
$balance = mycred_get_users_balance( $user_id, 'piq_credits' );
if( (is_user_logged_in()) && (piq_user_has_posts($user->ID)) && ($balance != '0') ) { ?>
The piq_user_has_posts function is --
function piq_user_has_posts($user_id) {
$result = new WP_Query(array(
'author'=>$user_id,
'post_type'=>'post_type_b',
'post_status'=>'publish',
'posts_per_page'=>1,
));
return (count($result->posts)!=0);
}
What I need now is to be able to check - if $customfield1 = $customfield2 then do something
Again, each custom field is from a different post type and Im doing this on a single post page for one of those post types.
So far I tried the following --
$users_query = new WP_Query( array(
'post_type' => 'piq_request',
'meta_key' => 'piq_link',
'meta_value' => $piq_link,
) );
//echo $piq_link;
echo $this_property_id;
if($piq_link == $this_property_id) {