Removing end date and time

Home Forums Calendar Products Events Calendar PRO Removing end date and time

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #153103
    realbig
    Participant

    I’m posting this not so much for support as really just to share something with others and possibly get feedback on my method.

    I got a request from a client I’m building a site for that at first really challenged me for a few minutes. The request was to remove the end date and time from all events. My client had no use for this feature and didn’t ever want this information to display. I wasn’t aware of any simple way to accomplish this so I eventually had to devise a hack of sorts to make it happen. Then I thought to myself “I should share this over on the tri.be forum” so here I am.

    Basically here’s what I did:

    First off, I recognized that if the start date and time were the same as the end date and time, only the start info would display. So I ended up creating this little function which I threw in my functions.php file and seems to do the trick:

    function rbm_remove_event_date($post_id) {
    $post_type = get_post_type( $post_id );
    if ($post_type != ‘tribe_events’) {
    return;
    } else {
    $start_date = get_post_meta($post_id, ‘_EventStartDate’, true);
    update_post_meta($post_id, ‘_EventEndDate’, $start_date);
    }
    }
    add_action(‘save_post’, ‘rbm_remove_event_date’, 99);

    What this does is just sets the end event date and time to be the same as the start date and time when the post is saved.

    Next I went along and hid the fields on the edit posts screen with some CSS:

    #EventInfo .eventtable tbody tr:nth-of-type(4) {
    display: none;
    }

    There it is. I just wanted to share this. I guess if someone has feedback on maybe a better way I’d be curious to see it. Or if someone spots flaws in this approach.

    Anyway, thanks for developing this great plugin.

    #153155
    Casey D
    Member

    Hello realbig,

    Thanks for sharing!

    Out of curiosity, what is the situation where start and end times are irrelevant?

    Thanks!

    – Casey Driscoll

    #153160
    realbig
    Participant

    Oh I guess the client just has no use for specifying an end time. All events are relatively similar and have a specific starting point but an end time is meaningless to both the organization and the attendees. The events are mostly running races with other activities where an end point doesn’t mean anything to anyone as long as you are present at the start.

    Kinda strange I know. I should share some of the other hacks I’ve had to come up with using this plugin. A couple instances where I was wishing I had few more actions and filters to work with but mostly this is an excellent plugin.

    #153888
    Casey D
    Member

    Hello realbig,

    That is interesting. Feel free to contact us again with any other hacks or ideas!

    We’d love it if you would leave us a review and let people know how much you like the plugin! http://m.tri.be/jt

    I’ll go ahead and close this thread. Let us know if we can help with anything else.

    – Casey Driscoll

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Removing end date and time’ is closed to new replies.