Ecommerce Shopify WordPress Discussion

Hide post when ACF custom date field has passed

I'm trying to adjust some code I've used in he past to allow for a specific user role. When the custom post type for an event passes a certain date (ACF field) the post is no longer visible. <section class="first-event"> <div class="container px-5 px-sm-0"> <?php if (current_user_can('stallholder')) $today = date('Ymd', strtotime("-10 days")); else $today = date('Ymd'); $args = array( 'post_type' => array( 'product' ), 'posts_per_page' => '1', 'meta_key' => 'event_start_date', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array( // only display if custom date hasn't passed 'relation' => 'OR', array( 'key' => 'event_end_date', 'value' => $today, 'compare' => '>=', 'type' => 'numeric' ), array( 'key' => 'event_end_date', 'value' => '', 'compare' => '=', ), ), ); // The Query $events_query = new WP_Query( $args ); ?> <?php while ( $events_query->have_posts() ) { $events_query->the_post(); ?> <div class="row g-0" style="background-color:<?php the_field('event_colour'); ?>"> <div class="<?php $categories = get_the_category(get_the_id()); foreach ($categories as $category) {echo $category->slug.' '; }?>" id="content-wide"> <article class="events-wrapper"> <a class="link-wrap" href="<?php the_permalink();?>"></a> <div class="row g-0 align-items-center"> <div class="col-md-6 g-0 order-2 order-md-1"> <div class="events-body"> <h3><?php the_field('event_title'); ?></h3> <ul id="event-info"> <li class="small-title">Date<span class="colon-space">: </span></br><span><?php the_field('date'); ?></span></li> <li class="small-title">Location<span class="colon-space">: </span></br><span><?php the_field('location'); ?></span></li> <li class="small-title">Price<span class="colon-space">: </span></br><span><?php the_field('price'); ?></span></li> </ul> <?php the_excerpt();?> </div> </div> <div class="col-md-6 g-0 order-1 order-md-2"> <div class="events-image" style="background-image: url('<?php the_post_thumbnail_url();?>')"><?php the_post_thumbnail('3:2');?></div> </div> </div> </article> </div> </div> <?php } ?> </div> </section> What I'm trying achieve is when a specific user role (stallholder) is logged in the event is hidden 10 days prior. NB. When I tried just implementing $today = date('Ymd', strtotime("-10 days")); on it's own and not in an if statement it didn't work either.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.