I want to hide a div based on whether it has certain fields are not empty but this needs to be either/or since there will be times when one field is filled in but another is not. I had a solution here:
https://toolset.com/forums/topic/hiding-a-complete-div-if-all-conditionals-are-met/
But now I want to add another field in to the code.
Here is code
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
add_filter( 'ddl_render_row_start', function( $markup, $args, $row, $renderer ){
global $post;
$is_empty = false;
if($args['additionalCssClasses']=='pop-culture-box') {
$value = get_post_meta($post->ID,'wpcf-pop-culture-spotify-playlists-link',true);
if(empty($value)){
$args['additionalCssClasses'] = "hidden";
$is_empty = true;
}
}
if( $is_empty ){
ob_start();?>
<<?php echo $args['tag']; ?> class="hidden"<?php if ($args['cssId']) { echo ' id="' . $args['cssId'] . '"'; } ?> >
<?php
$markup = ob_get_clean();
}
return $markup;
}, 99, 4 );
I want to add wpcf-video-2-id as another option. If wpcf-video-2-id is not empty it should show the div. How do I add that as an OR option to this line:
$value = get_post_meta($post->ID,'wpcf-pop-culture-spotify-playlists-link',true);
Thanks
Hello,
Please try to modify these lines from:
...
if(empty($value)){
...
With:
...
$video_2_id = get_post_meta($post->ID,'wpcf-video-2-id',true);
if(empty($value) && empty($video_2_id)){
...
My issue is resolved now. Thank you!