Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('save_post', 'save_my_post_meta');
- function save_my_post_meta($post_id) {
- // Bail if we're doing an auto save
- if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- // if our current user can't edit this post, bail
- if( !current_user_can( 'edit_post' ) ) return;
- // now we can actually save the data
- $allowed = array(
- 'a' => array( // on allow a tags
- 'href' => array() // and those anchors can only have href attribute
- )
- );
- // If any value present in input field, then update the post meta
- if(isset($_POST['mytext'])) {
- // $post_id, $meta_key, $meta_value
- update_post_meta( $post_id, 'mytext', $_POST['mytext'] );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement