Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Adds the custom fields to the registration form and profile editor
- *
- */
- function pw_rcp_add_user_fields() {
- $website_url = get_user_meta( get_current_user_id(), 'rcp_website_url', true );
- ?>
- <p>
- <label for="rcp_website_url"><?php _e( 'Your Website URL', 'rcp' ); ?></label>
- <input name="rcp_website_url" id="rcp_website_url" type="text" value="<?php echo esc_attr( $website_url ); ?>"/>
- </p>
- <?php
- }
- add_action( 'rcp_after_password_registration_field', 'pw_rcp_add_user_fields' );
- add_action( 'rcp_profile_editor_after', 'pw_rcp_add_user_fields' );
- /**
- * Adds the custom fields to the member edit screen
- *
- */
- function pw_rcp_add_member_edit_fields( $user_id = 0 ) {
- $website_url = get_user_meta( $user_id, 'rcp_website_url', true );
- ?>
- <tr valign="top">
- <th scope="row" valign="top">
- <label for="rcp_website_url"><?php _e( 'website_url', 'rcp' ); ?></label>
- </th>
- <td>
- <input name="rcp_website_url" id="rcp_website_url" type="text" value="<?php echo esc_attr( $website_url ); ?>"/>
- <p class="description"><?php _e( 'The member\'s website URL', 'rcp' ); ?></p>
- </td>
- </tr>
- <?php
- }
- add_action( 'rcp_edit_member_after', 'pw_rcp_add_member_edit_fields' );
- /**
- * Determines if there are problems with the registration data submitted
- *
- */
- function pw_rcp_validate_user_fields_on_register( $posted ) {
- if( empty( $posted['rcp_website_url'] ) ) {
- rcp_errors()->add( 'invalid_website_url', __( 'Please enter your website URL', 'rcp' ), 'register' );
- }
- }
- add_action( 'rcp_form_errors', 'pw_rcp_validate_user_fields_on_register', 10 );
- /**
- * Stores the information submitted during registration
- *
- */
- function pw_rcp_save_user_fields_on_register( $posted, $user_id ) {
- if( ! empty( $posted['rcp_website_url'] ) ) {
- update_user_meta( $user_id, 'rcp_website_url', sanitize_text_field( $posted['rcp_website_url'] ) );
- }
- }
- add_action( 'rcp_form_processing', 'pw_rcp_save_user_fields_on_register', 10, 2 );
- /**
- * Stores the information submitted profile update
- *
- */
- function pw_rcp_save_user_fields_on_profile_save( $user_id ) {
- if( ! empty( $_POST['rcp_website_url'] ) ) {
- update_user_meta( $user_id, 'rcp_website_url', sanitize_text_field( $_POST['rcp_website_url'] ) );
- }
- }
- add_action( 'rcp_user_profile_updated', 'pw_rcp_save_user_fields_on_profile_save', 10 );
- add_action( 'rcp_edit_member', 'pw_rcp_save_user_fields_on_profile_save', 10 );
- // display the info in the members list
- function website_url_add_table_header_footer() {
- ?>
- <th class="rcp-website_url-col"><?php _e('Website URL', 'rcp'); ?></th>
- <?php
- }
- add_action('rcp_members_page_table_header', 'website_url_add_table_header_footer');
- add_action('rcp_members_page_table_footer', 'website_url_add_table_header_footer');
- function website_url_add_row($user_id) {
- ?>
- <td><?php echo get_user_meta($user_id, 'rcp_website_url', true); ?></td>
- <?php
- }
- add_action('rcp_members_page_table_column', 'website_url_add_row');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement