Advertisement
Guest User

Untitled

a guest
Sep 14th, 2012
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. add_action('add_meta_boxes', 'jpg_affiliated');
  2. function jpg_affiliated()
  3. {
  4.     add_meta_box('jpg_affiliated_staff', 'Who Was Involved?', 'jpg_affiliated_staff_callback', 'post', 'normal', 'default');    
  5. }
  6. function jpg_affiliated_staff_callback($post)
  7. {
  8.     global $post;
  9.     $custom = get_post_custom($post->ID);
  10.     wp_nonce_field('jpg_affiliated_nonce', 'jpg_affiliated_nonce_field');
  11. ?>
  12.     <p><strong>Select any staff that were involved in this event and what their role was.</strong></p>
  13.     <div style="overflow:hidden;padding:0 0 10px 0">
  14.         <table>
  15.             <tr>
  16.                 <td width="10%"><input type="checkbox" id="jpg_team_member" name="jpg_team_member" value="Test"<?php if(get_post_meta($post->ID,'jpg_team_member', true ) == "Test" ){echo ' checked="checked"';}  ?>></td>
  17.                 <td width="40%"><label for="jpg_team_member">Test</label></td>
  18.                 <td width="50%">
  19.                 <select name="" id="">
  20.                 <option value="">Select role...</option>
  21.                 <option value="Primary Shooter">Primary Shooter</option>
  22.                 <option value="Second Shooter">Second Shooter</option>
  23.                 <option value="Third Shooter">Third Shooter</option>
  24.                 <option value="Lighting Assitant">Lighting Assistant</option>
  25.                 <option value="Photo Booth Coordinator">Photo Booth Coordinator</option>
  26.                 <option value="Marketing Coordinator">Marketing Coordinator</option>
  27.                 <option value="Studio Manager">Studio Manager</option>
  28.                 <option value="JPG Team Member">JPG Team Member</option>
  29.                 <option value="Photogrpaher">Photographer</option>
  30.                 </select>                
  31.                 </td>
  32.             </tr>
  33.         </table>
  34.     </div>    
  35. <?php
  36. }
  37.  
  38. add_action('save_post', 'jpg_save_staff');
  39. function jpg_save_staff($post_id)
  40. {
  41.     // Bail if we're doing an auto save
  42.     if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
  43.  
  44.     // if our nonce isn't there, or we can't verify it, bail
  45.     if(!isset($_POST['jpg_affiliated_nonce_field']) || !wp_verify_nonce($_POST['jpg_affiliated_nonce_field'], 'jpg_affiliated_nonce' )) return;
  46.  
  47.     // if our current user can't edit this post, bail
  48.     if(!current_user_can('edit_post')) return;
  49.  
  50.     // Probably a good idea to make sure your data is set        
  51.     if(isset($_POST['jpg_team_member'])){update_post_meta($post_ID, 'jpg_team_member', esc_attr($_POST['jpg_team_member']));} else {update_post_meta($post_ID, 'jpg_team_member','');}
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement