Home Forums Event Espresso Premium Active status for multiple datetimes Reply To: Active status for multiple datetimes

Reply To: Active status for multiple datetimes

Author Replies
motio # Posted on March 25, 2018 at 12:48 pm

So I went through the classes and I guess I kinda get it. Here is my code for the custom banner and is working.

// Add custom banner after the content
add_action('AHEE_event_details_after_the_content', 'my_test_function');
function my_test_function() {

    $today = time();

  	$first_date_object = EEH_Event_View::get_primary_date_obj( );
		$first_date_timestamp = $first_date_object instanceof EE_Datetime ? $first_date_object->get_raw( 'DTT_EVT_start' ) :  '';

    $last_date_object = EEH_Event_View::get_last_date_obj( );
		$last_date_timestamp = $last_date_object instanceof EE_Datetime ? $last_date_object->get_raw( 'DTT_EVT_end' ) :  '';

    $get_event = EEH_Event_View::get_event();
    $event_is_canceled = $get_event instanceof EE_Event ? $get_event->is_cancelled() :  '';
    $event_is_soldout = $get_event instanceof EE_Event ? $get_event->is_sold_out() :  '';

    if ($event_is_canceled==true) {
    echo "<span class=\"banner banner_canceled\">canceled</span>";
  }   elseif ($event_is_soldout==true){
    echo "<span class=\"banner banner_sold_out\">event is sold out</span>";
  }   elseif ($today < $first_date_timestamp){
    echo "<span class=\"banner banner_open\">open for registration</span>";
  }   elseif ($first_date_timestamp < $today && $today < $last_date_timestamp){
    echo "<span class=\"banner banner_pending\">pending</span>";
  }   elseif ($last_date_timestamp < $today){
    echo "<span class=\"banner banner_expired\">expired</span>";

And the CSS to that belongs to that banner.

add_action( 'wp_head', 'css_for_custom_plugin_functions_ee' );
function css_for_custom_plugin_functions_ee() {
    <style type="text/css">

display: inline-block;
position: relative;
float: right;
z-index: 1;
padding: 0.5em 1.5em 0.5em;
margin: 0 0 0 1em;
border-bottom: 1px solid rgba(0,0,0,0.1);
font-weight: bold;
color: #fff !important;
text-decoration: none;
text-align: center;
text-shadow: 0 -1px 0 rgba(0,0,0,0.25);
font-size: 1.5em;
line-height: 1;
border-radius: 0;
box-shadow: none;

background-color: red;
background-color: orange;
background-color: #00B1CA;
background-color: green;
background-color: grey;


Even though the code works, I am not sure exactly what is stored in the variables. Becomes the variable an object of the class?

If it’s possible it would be great to get some infos to my questions from my previous post to understand the ee system better.

Do NOT follow this link or you will be banned from the site!