Support » Plugin: WordPress Countdown Widget » Automaticly pick up next upcoming event from plugin Events Manager

Viewing 3 replies - 1 through 3 (of 3 total)
  • Menno1987

    (@menno1987)

    I’ve almost got it working now. It’s just the day that’s not working right yet. (see “date” in shortcode). When i echo the day out in PHP it seems to be just fine. But when i try to apply it in the shortcode, the entire countdown widget just disappears/crashes. Could anyone please help me? Any help would be much appreciated 🙂

    P.s. I’m using PHP in the shortcode in a Widget area with another plugin that supports both and together in a Text Widget box.

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php
    global $wpdb;
    $canUpdate = false;
    $currentDay = date("Y-m-d");
    
    $query = "SELECT event_name, event_start_date, event_start_time FROM wp_em_events WHERE event_start_date > '".$currentDay."' AND event_status = 1 ORDER BY event_start_date ASC LIMIT 1";
    $result = $wpdb->get_results($query);
    if ($result) {
    $canUpdate = true;
    
    foreach($result as $row){
    $nextEventName = $row->event_name;
    $nextEventDate = $row->event_start_date;
    $nextEventTime = $row->event_start_time;
    $nextEventDateAr = explode("-", $nextEventDate);
    $nextEventTimeAr = explode(":", $nextEventTime);
    $nextEventYear = $nextEventDateAr[0];
    $nextEventMonth = $nextEventDateAr[1];
    $nextEventDay = $nextEventDateAr[2];
    $nextEventHour = $nextEventTimeAr[0];
    $nextEventMinutes = $nextEventTimeAr[1];
    $nextEventSeconds = $nextEventTimeAr[2];
       }
    }
    
    $mydate = strtotime('$nextEventDay');
    $newday = date('l', $mydate);
    echo $newday;
    ?>
    [countdown
    title=""
    event="<?= $nextEventName ?>"
    date="<?= $newday ?>"
    hour="<?= $nextEventHour ?>"
    minutes="<?= $nextEventMinutes ?>"
    seconds="<?= $nextEventSeconds ?>"
    format="DHMS"]
    Menno1987

    (@menno1987)

    After spending about two days pulling my hair out, atleast i don’t have to get a haircut anymore. But i’ve finally done it with the code below.

    The code i’ve used pulls the time and date for the next upcoming event and works in conjunction with the plugin Events Manager and shows the ETA for the next upcoming event that takes place atleast the next day (NOT on the day itself). For my client that was good enough so i’m very happy. For anyone else that wants to do the same thing, i’m sharing my code here below.
    Plugins needed:
    *Countdown Timer
    *Events Manager

    Code:

    <?php
    global $wpdb;
    $canUpdate = false;
    $currentDay = date("Y-m-d");        
    
    $query = "SELECT event_name, event_start_date, event_start_time FROM wp_em_events WHERE event_start_date > '".$currentDay."' AND event_status = 1 ORDER BY event_start_date ASC LIMIT 1";
    $result = $wpdb->get_results($query);
    if ($result) {
    	$canUpdate = true;
    
         foreach($result as $row)
    	 {
    		 $nextEventName = $row->event_name;
    		 $nextEventDate = $row->event_start_date;
    		 $nextEventTime = $row->event_start_time;
    		 $nextEventDateAr = explode("-", $nextEventDate);
    		 $nextEventTimeAr = explode(":", $nextEventTime);
    		 $nextEventYear = $nextEventDateAr[0];
    		 $nextEventMonth = $nextEventDateAr[1];
    		 $nextEventDay = $nextEventDateAr[2];
    		 $nextEventHour = $nextEventTimeAr[0];
    		 $nextEventMinutes = $nextEventTimeAr[1];
    		 $nextEventSeconds = $nextEventTimeAr[2];
         }
    }
     ?>
    [countdown
    event="<?= $nextEventName ?>"
    day="<?= $nextEventDay ?>"
    month="<?= $nextEventMonth ?>"
    year="<?= $nextEventYear ?>"]

    Menno1987

    (@menno1987)

    Resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Automaticly pick up next upcoming event from plugin Events Manager’ is closed to new replies.