Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function office_rw($post_id) {
- // If it is our form has not been submitted, so we dont want to do anything
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || $post->post_status == 'trash')
- return;
- /*Don't do this more than one time*/
- if(get_transient('office-being-created') != 'true'){
- //Temporarily disable this filter
- remove_action('save_post', 'office_rw', 9999, 1);
- $locID = $post_id;
- if($_POST['post_type'] == 'location' && get_post_meta($post_id, '_office-created', true) != 'true'){
- update_post_meta($post_id, '_office-created', 'true');
- set_transient('office-being-created', 'true', 10);
- $office_home = array();
- $office_title = get_the_title($post_id);
- $office_home['post_name'] = sanitize_title_with_dashes($office_title);
- $office_home['post_title'] = $office_title;
- $office_home['post_status'] = 'publish';
- $office_home['post_type'] = 'office';
- $homeID = wp_insert_post($office_home);
- update_post_meta($homeID, 'wpcf-location-list', $locID);
- update_post_meta($homeID, 'wpcf-office-type', 'office-home');
- }
- }
- //restore save
- add_action('save_post', 'office_rw', 9999, 1);
- }
- add_action('save_post', 'office_rw', 9999, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement