Created
September 4, 2014 12:48
-
-
Save chrisblackwell/ebbb3bc83acfab4442e5 to your computer and use it in GitHub Desktop.
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
/** | |
* Saves the meta box field data | |
* | |
* @param int $post_id Post ID | |
*/ | |
function save_meta_boxes( $post_id ) { | |
// Check if our nonce is set. | |
if ( ! isset( $_POST['{name}_nonce'] ) ) { | |
return $post_id; | |
} | |
// Verify that the nonce is valid. | |
if ( ! wp_verify_nonce( $_POST['{name}_nonce'], '{save_post}' ) ) { | |
return $post_id; | |
} | |
// Check this is the Contact Custom Post Type | |
if ( '{post_type_name}' != $_POST['post_type'] ) { | |
return $post_id; | |
} | |
// Check the logged in user has permission to edit this post | |
if ( ! current_user_can( 'edit_post', $post_id ) ) { | |
return $post_id; | |
} | |
// OK to save meta data | |
$email = sanitize_text_field( $_POST['contact_email'] ); | |
update_post_meta( $post_id, '_contact_email', $email ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment