Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- This snippet limits the number of recurrences a recurring event can create. Change $limit accordingly.
- For installation instructions please see this documentation:
- http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
- */
- /**
- * @param bool $result
- * @param EM_Event $EM_Event
- * @return boolean
- */
- function my_em_recurring_events_limit( $result, $EM_Event ){
- if( $result && $EM_Event->is_recurring() ){
- $limit = 5;
- $matching_days = $EM_Event->get_recurrence_days();
- $count = count($matching_days);
- if( $count > $limit ){
- $EM_Event->add_error("You can only create a maxumum of $limit events, you are trying to create $count events. Please change your date schedule accordingly.");
- return false;
- }
- }
- return $result;
- }
- add_filter('em_event_validate_meta', 'my_em_recurring_events_limit', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement