Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function wedevs_save_top( $post_id ) {
- // make sure something has been submitted from our nonce
- if ( !isset($_POST[$key . '_wpnonce']) )
- return $post_id;
- // verify this came from the our screen and with proper authorization,
- // because save_post can be triggered at other times
- if ( !wp_verify_nonce($_POST[$key . '_wpnonce'], basename(__FILE__)) )
- return $post_id;
- // verify if this is an auto save routine.
- // if it is our form and it has not been submitted, dont want to do anything
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
- return $post_id;
- // lastly check to make sure this user has permissions to save post fields
- if ( !current_user_can('edit_post', $post_id) )
- return $post_id;
- if( isset( $_POST['top_ad'] ) ) {
- update_post_meta( $post_id, 'top_ad', $_POST['top_ad'] );
- }
- }
- add_action( 'save_post', 'wedevs_save_top' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement