Last active
December 16, 2020 17:03
-
-
Save ajgagnon/7a028a12c9230a833fc2461496eb2afd to your computer and use it in GitHub Desktop.
Limit tasks for clients
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter("rest_pre_insert_phw_comment_loc", "wp_145_limit_tasks", 10, 2); | |
| function wp_145_limit_tasks($prepared_post, $request) { | |
| if(!$project_id = $prepared_post->meta_input['project_id']) { | |
| return $prepared_post; | |
| } | |
| // if it's our project | |
| if ($project_id === 5) { | |
| $status = ph_get_website_resolve_status($project_id); | |
| $active = $status['total'] = $status['resolved']; | |
| // if we have more than 5 active tasks | |
| if ($active > 5) { | |
| return new WP_Error('task_limit', 'You have reached your task limit.'); | |
| } | |
| } | |
| return $prepared_post; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment