Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. /* add an extra field to users to check if they registered */
  2.  
  3. function defunktnu_add_custom_user_profile_fields($user) {
  4. ?>
  5.     <h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3>
  6.     <table class="form-table">
  7.         <tr>
  8.             <th>
  9.                 <label for="address"><?php _e('Address', 'your_textdomain'); ?>
  10.             </label></th>
  11.             <td>
  12.                 <input type="text" name="address" id="address" value="<?php echo esc_attr( get_user_meta( $user->ID, 'address', true) ); ?>" class="regular-text" /><br />
  13.                 <span class="description"><?php _e('Please enter your address.', 'your_textdomain'); ?></span>
  14.             </td>
  15.         </tr>
  16.         <tr>
  17.             <th>
  18.                 <label for="address"><?php _e('Al geregistreerd', 'your_textdomain'); ?>
  19.             </label></th>
  20.             <td>
  21.                 <?php
  22.                     $checked == "";
  23.                     if(get_user_meta( $user->ID, 'registered', true) == "Ja") {
  24.                         $checked = " checked=\"checked\"";
  25.                     }
  26.                 ?>
  27.                 <input type="checkbox" name="registered"<?=$checked?> id="registered" value="Ja" class="regular-text" /><br />
  28.             </td>
  29.         </tr>
  30.     </table>
  31. <?php }
  32.  
  33. function fb_save_custom_user_profile_fields( $user_id ) {
  34.     if ( !current_user_can( 'edit_user', $user_id ) )
  35.         return FALSE;
  36.     //echo("*" . $_POST['registered']);exit();
  37.     update_usermeta( $user_id, 'address', $_POST['address'] );
  38.     update_usermeta( $user_id, 'registered', $_POST['registered'] );
  39. }
  40.  
  41. add_action( 'show_user_profile', 'defunktnu_add_custom_user_profile_fields' );
  42. add_action( 'edit_user_profile', 'defunktnu_add_custom_user_profile_fields' );
  43. add_action( 'personal_options_update', 'fb_save_custom_user_profile_fields' );
  44. add_action( 'edit_user_profile_update', 'fb_save_custom_user_profile_fields' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement