Advertisement
Guest User

Custom fields regsitrations form - Restrict content pro

a guest
Sep 6th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Custom Fields Registration - RCP
  4. Plugin URL: http://wordpress.org/extend/plugins/custom-fields-registration-rcp/
  5. Description: Adds a simple custom fields to the Restrict Content Pro registration form made by DannIkhim for AAFW !
  6. Version: 1.0.0
  7. Author: Dann Ikhim
  8. Author URI: http://webinkdesign.ro
  9. Contributors: Dann Ikhim
  10. License: GPL2
  11. Text Domain: custom-fields-registration
  12. */
  13.  
  14. // displays the custom fields to registration form
  15.  
  16.  
  17. function wid_add_custom_fields() {
  18.     ?>
  19.     <p>
  20.         <label for="rcp_location"><?php _e('Your City, State', 'rcp'); ?></label>
  21.         <input name="rcp_location" id="rcp_location" type="text"/>
  22.     </p>
  23.     <p>
  24.         <label for="rcp_address"><?php _e('Address', 'rcp'); ?></label>
  25.         <input name="rcp_address" id="rcp_address" type="text"/>
  26.     </p>
  27.     <p>
  28.         <label for="rcp_zip"><?php _e('Zip', 'rcp'); ?></label>
  29.         <input name="rcp_zip" id="rcp_address" type="text"/>
  30.     </p>
  31.     <p>
  32.         <label for="rcp_phone"><?php _e('Phone no', 'rcp'); ?></label>
  33.         <input name="rcp_phone" id="rcp_phone" type="text"/>
  34.     </p>
  35.     <?php
  36. }
  37. add_action('rcp_after_password_registration_field', 'wid_add_custom_fields');
  38.  
  39.  
  40. function wid_save_custom_fields($posted, $user_id) {
  41.     if($posted['rcp_location']) {
  42.         update_user_meta($user_id, 'rcp_location', $posted['rcp_location']);
  43.     }
  44.  
  45.     if($posted['rcp_address']) {
  46.         update_user_meta($user_id, 'rcp_address', $posted['rcp_address']);
  47.     }
  48.  
  49.     if($posted['rcp_zip']) {
  50.         update_user_meta($user_id, 'rcp_zip', $posted['rcp_zip']);
  51.     }
  52.  
  53.     if($posted['rcp_phone']) {
  54.         update_user_meta($user_id, 'rcp_phone', $posted['rcp_phone']);
  55.     }
  56. }
  57. add_action('rcp_form_processing', 'wid_save_custom_fields', 10, 2);
  58.  
  59.  
  60. function wid_add_table_header_footer() {
  61.     ?>
  62.     <th class="rcp-location-col"><?php _e('Location', 'rcp'); ?></th>
  63.     <th class="rcp-address-col"><?php _e('Street', 'rcp'); ?></th>
  64.     <th class="rcp-zip-col"><?php _e('Zip', 'rcp'); ?></th>
  65.     <th class="rcp-phone-col"><?php _e('Phone', 'rcp'); ?></th>
  66.     <?php
  67. }
  68. add_action('rcp_members_page_table_header', 'wid_add_table_header_footer');
  69. add_action('rcp_members_page_table_footer', 'wid_add_table_header_footer');
  70.  
  71.  
  72. function wid_add_row($user_id) {
  73.     ?>
  74.     <td><?php echo get_user_meta($user_id, 'rcp_location', true); ?></td>
  75.     <td><?php echo get_user_meta($user_id, 'rcp_address', true); ?></td>
  76.     <td><?php echo get_user_meta($user_id, 'rcp_zip', true); ?></td>
  77.     <td><?php echo get_user_meta($user_id, 'rcp_phone', true); ?></td>
  78.     <?php
  79. }
  80. add_action('rcp_members_page_table_column', 'wid_add_row');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement