Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class bbg_user_meta {
- function bbg_user_meta() {
- if ( is_admin() ) {
- add_action('show_user_profile', array(&$this,'action_show_user_profile'));
- add_action('edit_user_profile', array(&$this,'action_show_user_profile'));
- add_action('personal_options_update', array(&$this,'action_process_option_update'));
- add_action('edit_user_profile_update', array(&$this,'action_process_option_update'));
- }
- }
- function action_show_user_profile($user) {
- $is_teacher = (get_the_author_meta('acct_type', $user->ID) == 'teacher' ? true : false );
- ?>
- <h3><?php _e('Account Type') ?></h3>
- <table class="form-table">
- <tr>
- <th><label for="acct_type"><?php _e('Account type'); ?></label></th>
- <td>
- <select name="acct_type">
- <option value="teacher" <?php if ( $is_teacher) : ?>selected="selected"<?php endif; ?>>Teacher</option>
- <option value="student" <?php if ( !$is_teacher) : ?>selected="selected"<?php endif; ?>>Student</option>
- </select>
- </td>
- </tr>
- </table>
- <?php
- }
- function action_process_option_update($user_id) {
- update_usermeta($user_id, 'acct_type', ( isset($_POST['acct_type']) ? $_POST['acct_type'] : '' ) );
- }
- }
- /* Initialise outselves */
- 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