Nigel will be away until Tuesday, but I'll be happy to assist you with your question.
As Nigel mentioned in his message, the "wp_redirect" needs to be called before the page's rendering/output has started. This is why using it with "wpv-conditional" shortcode won't work.
To include a check for the value of a custom field "only-login-user", you can update the code from:
function tssupp_redirect() {
if ( !is_user_logged_in() && is_singular('product') ) {
wp_redirect(home_url());
exit;
}
}
add_action('template_redirect', 'tssupp_redirect');
To:
function tssupp_redirect() {
if ( !is_user_logged_in() && is_singular('product') ) {
// get the custom field value
$field_check = types_render_field( "only-login-user", array( ) );
// redirect only if the value for the custom field "only-login-user" is not empty
if(!empty($field_check)) {
wp_redirect(home_url());
exit;
}
}
}
add_action('template_redirect', 'tssupp_redirect');
The above code will make sure that the redirection only happens for those products, for which the value for the custom field "only-login-user" exists or is not empty.