Advertisement
Guest User

Untitled

a guest
Jul 8th, 2010
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. class bbg_user_meta {
  2.  
  3.      function bbg_user_meta() {
  4.          if ( is_admin() ) {
  5.              add_action('show_user_profile', array(&$this,'action_show_user_profile'));
  6.              add_action('edit_user_profile', array(&$this,'action_show_user_profile'));
  7.              add_action('personal_options_update', array(&$this,'action_process_option_update'));
  8.              add_action('edit_user_profile_update', array(&$this,'action_process_option_update'));
  9.          }
  10.  
  11.      }
  12.  
  13.      function action_show_user_profile($user) {
  14.  
  15.      $is_teacher = (get_the_author_meta('acct_type', $user->ID) == 'teacher' ? true : false );
  16. ?>
  17.          <h3><?php _e('Account Type') ?></h3>
  18.  
  19.          <table class="form-table">
  20.             <tr>
  21.                 <th><label for="acct_type"><?php _e('Account type'); ?></label></th>
  22.                     <td>
  23.                         <select name="acct_type">
  24.                             <option value="teacher" <?php if ( $is_teacher) : ?>selected="selected"<?php endif; ?>>Teacher</option>
  25.                             <option value="student" <?php if ( !$is_teacher) : ?>selected="selected"<?php endif; ?>>Student</option>
  26.                         </select>
  27.  
  28.  
  29.                     </td>
  30.             </tr>
  31.          </table>
  32. <?php
  33.      }
  34.  
  35.      function action_process_option_update($user_id) {
  36.          update_usermeta($user_id, 'acct_type', ( isset($_POST['acct_type']) ? $_POST['acct_type'] : '' ) );
  37.      }
  38. }
  39. /* Initialise outselves */
  40. add_action('plugins_loaded', create_function( '', 'global $bbg_user_meta_instance; $bbg_user_meta_instance = new bbg_user_meta();' ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement