Advertisement
foomagoo

Save checkboxes

Mar 21st, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. add_action('save_post', 'save_couponbooks');
  3.  
  4. function save_couponbooks($post_id) {
  5. global $post;
  6. if ($post->post_type != "coupon" || ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) || !current_user_can( 'edit_coupon', $post->ID )) {
  7. return $post->ID;
  8. }
  9. $couponbooks = array();
  10. foreach($_POST['tax_input']['couponbook'] as $couponbook) {
  11. if (is_numeric($couponbook)) {
  12. $couponbook = get_term($couponbook, 'couponbook');
  13. if (!is_wp_error($couponbook)) {
  14. $couponbooks[] = $couponbook->slug;
  15. }
  16. }
  17. }
  18. wp_set_object_terms($post->ID, $couponbooks, 'couponbook', false);
  19. }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement