- This topic has 1 reply, 2 voices, and was last updated 11 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘How do I …’ is closed to new topics and replies.
Events Made Easy › Forums › How do I … › How do I filter event_status on event insert?
Franky,
I have done some event validation using the eme_insert_event_action hook.
On certain conditions, I would like to over-ride the value of post_status and set to 3 (draft) to ensure the user corrects the errors before the event is published.
I think this would be using the filter; eme_event_filter
I’ve added some code similar to the following, but unsure where to place it as I’m already using an action hook?
<br />
function pstv_unpub_event($event) {<br />
// Check if we can publish or not<br />
$event[event_status] = 3;<br />
}<br />
}</p>
<p>add_filter('eme_event_filter','pstv_unpub_event');<br />
I’ve tried a few things but can’t get it to work.
Should it go before/inside/after the hook function?
I already tried to do it in the action hook, but it wouldn’t work which was why I changed to using the filter.
Thanks
Yeah, that filter is applied when retrieving the event, not when inserting it.
So you might want to apply this change, that is applied just before the event is inserted in the DB:
http://plugins.trac.wordpress.org/changeset/811618
But, concerning filters; read this: http://codex.wordpress.org/Function_Reference/add_filter
In short: you need a “return” statement in your function. In your case, just this might already help:
function pstv_unpub_event($event) {
// Check if we can publish or not
$event[event_status] = 3;
return $event;
}