If I understood correctly, I believe this will help you to get what you’re after. I can’t verify it works, but reading it should give some guidance:
function my_plugin_verify() {
// --------------------------------------------------------------------------
// 1) I'm checking if the user is logged in
if (!is_user_logged_in())
return false; // NOT VERIFIED
// --------------------------------------------------------------------------
// 2) if he has published any posts (submitted forms) in post_typeB
$user_id = get_current_user_id();
// get all posts_typeB by $user_id
$users_posts_typeB = get_posts(array(
'author' => $user_id,
'post_type' => 'post_typeB',
'post_status' => 'publish',
'posts_per_page' => -1,
));
// if no posts, NOT VERIFIED
if (count($users_posts) < 1)
return false;
// --------------------------------------------------------------------------
// 3) is custom_field_1 in $users_posts_typeB in post type B empty or not
$custom_field_1_values = array();
// cycle through post_typeB posts by $user_id
foreach ($users_posts_typeB as $apost) {
// see if custom_field_1 is not empty in all them
$custom_field_1 = get_post_meta($apost->ID,'custom_field_1',true);
// if custom_field_1 empty, user is NOT VERIFIED
if (empty($custom_field_1) || empty($custom_field_1))
return false;
// if custom_field_1 has value, record it for comparison next
else
$custom_field_1_values[] = $custom_field_1;
}
// --------------------------------------------------------------------------
// 4) does the value match the value of custom field (2) of any posts in post type A that is currently being viewed
// we'll presume no matches
$matchFound = false;
// we'll query all post_typeA, looking for a custom_field_2 with the value of all above custom_field_1 value's
foreach ($custom_field_1_values as $custom_field_1_value) {
$matchingCustomValue = get_posts(array(
'post_type' => 'post_typeA',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'custom_field_2',
'meta_value' => $custom_field_1_value,
));
// if there's a match, we'll note it
if (count($matchingCustomValue) > 0)
$matchFound = true;
}
// if there's no match, user is NOT VERIFIED
if (!$matchFound)
return false;
// --------------------------------------------------------------------------
// 5) Is the mycred (plugin) balance is empty or not
$balance = mycred_get_users_balance( $user_id, 'piq_credits' );
if ($balance == '0')
return false
// --------------------------------------------------------------------------
// they got this far, they're verified
return true;
}
And you’d just argue the function
if ( my_plugin_verify() )
// user meets criteria
// display content
)
I’m wasn’t sure what “is currently being viewed” meant in (4) and how you’d monitor that.
I wasn’t sure if post_typeB would return more than one post, or if custom_field_1 could exists for a user more than one. I wrote it for multiples.
If your queries don’t have to happen real-time and aren’t constantly updating, you’ll want to look into transients to save the verification state instead of querying each time.