Modify meta data when add post
-
Hi, please tell me what I’m doing wrong. On my site automatically adding events (CPT) from facebook with two meta fields:
- ev_date_start
- ev_date_end
all ok, automatically adding events with all necessary fields but some time in source (facebook) ev_date_end is empty…. its broke post…
I came up with the following solution:add_action( 'added_post_meta', 'save_post_event', 10, 4 ); function save_post_event( $meta_id, $post_id, $meta_key, $meta_value ){ if ( get_post_type( $post_id ) != 'event' ){ return; } if ( $meta_key == 'ev_date_end') { if ( $meta_value == '') { $start = strtotime(get_post_meta ( $post_id, "ev_date_start", true)+ 3600); update_post_meta( $post_id, 'ev_date_start', strtotime($start) ); } } }
but with this code both my field (ev_date_start, ev_date_end) are empty.
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Modify meta data when add post’ is closed to new replies.