Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action('save_post', 'save_couponbooks');
- function save_couponbooks($post_id) {
- global $post;
- if ($post->post_type != "coupon" || ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) || !current_user_can( 'edit_coupon', $post->ID )) {
- return $post->ID;
- }
- $couponbooks = array();
- foreach($_POST['tax_input']['couponbook'] as $couponbook) {
- if (is_numeric($couponbook)) {
- $couponbook = get_term($couponbook, 'couponbook');
- if (!is_wp_error($couponbook)) {
- $couponbooks[] = $couponbook->slug;
- }
- }
- }
- wp_set_object_terms($post->ID, $couponbooks, 'couponbook', false);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement