id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT ); $display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin'; $display = ( current_user_can( 'edit_users' ) ) ? 'admin' : $display; ?>

$field ) { $valtochk = ''; $values = ''; // Determine which fields to show in the additional fields area. $show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false; //$show = ( 'tos' == $meta && $field['register'] ) ? null : $show; if ( $show ) { $val = get_user_meta( $user_id, $meta, true ); $val = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? $val : htmlspecialchars( $val ); if ( $field['type'] == 'checkbox' ) { $valtochk = $val; $val = $field['checked_value']; } if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) { $values = $field['values']; $valtochk = $val; } // Is this an image or a file? if ( 'file' == $field['type'] || 'image' == $field['type'] ) { $empty_file = '' . __( 'None' ) . ''; if ( 'file' == $field['type'] ) { $attachment_url = wp_get_attachment_url( $val ); $input = ( $attachment_url ) ? '' . $attachment_url . '' : $empty_file; } else { $attachment_url = wp_get_attachment_image( $val, 'medium' ); if ( 'admin' == $display ) { $edit_url = admin_url( 'upload.php?item=' . $val ); $input = ( $attachment_url ) ? '' . $attachment_url . '' : $empty_file; } else { $input = ( $attachment_url ) ? $attachment_url : $empty_file; } } $input.= '
' . $wpmem->get_text( 'profile_upload' ) . '
'; $input.= wpmem_form_field( array( 'name' => $meta, 'type' => $field['type'], 'value' => $val, 'compare' => $valtochk, ) ); } else { if ( 'select' == $field['type'] || 'radio' == $field['type'] ) { $input = wpmem_create_formfield( $meta, $field['type'], $values, $valtochk ); } elseif( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) { $input = $wpmem->forms->create_form_field( array( 'name'=>$meta, 'type'=>$field['type'], 'value'=>$values, 'compare'=>$valtochk, 'delimiter'=>$field['delimiter'] ) ); } else { $field['type'] = ( 'hidden' == $field['type'] ) ? 'text' : $field['type']; $input = wpmem_create_formfield( $meta, $field['type'], $val, $valtochk ); } } // Is the field required? $req = ( $field['required'] ) ? ' ' . __( '(required)' ) . '' : ''; $label = ''; // Build the form rows for filtering. $rows[ $meta ] = array( 'meta' => $meta, 'type' => $field['type'], 'value' => $val, 'values' => $values, 'label_text' => __( $field['label'], 'wp-members' ), 'row_before' => '', 'label' => '', 'field_before' => '', 'row_after' => '', ); } } /** * Filter for rows. * * Filter is applied for the admin user edit ("wpmem_register_form_rows_admin") * and the user profile edit ("wpmem_register_form_rows_user"). * * @since 3.1.0 * @since 3.1.6 Deprecated $order. * * @param array $rows { * An array of the profile rows. * * @type string $meta The meta key. * @type string $type The field type. * @type string $value Value if set. * @type string $values Possible values (select, multiselect, multicheckbox, radio). * @type string $label_text Raw label text (no HTML). * @type string $row_before HTML before the row. * @type string $label HTML label. * @type string $field_before HTML before the field input tag. * @type string $field HTML for field input. * @type string $field_after HTML after the field. * @type string $row_after HTML after the row. * } * @param string $tag adminprofile|userprofile */ $rows = apply_filters( 'wpmem_register_form_rows_' . $display, $rows, $display . 'profile' ); // Handle form rows display from array. foreach ( $rows as $row ) { $show_field = $row['row_before'] . $row['label'] . $row['field_before'] . $row['field'] . $row['field_after'] . $row['field_after']; /** * Filter the profile field. * * Filter is applied for the admin user edit ("wpmem_admin_profile_field") * and the user profile edit ("wpmem_user_profile_field"). * * @since 2.8.2 * @since 3.1.1 Added $user_id and $row * * @param string $show_field The HTML string for the additional profile field. * @param string $user_id * @param array $row */ echo apply_filters( 'wpmem_' . $display . '_profile_field', $show_field, $user_id, $row ); } /** * Fires after generating the WP-Members fields in the user profile. * * Action fires for the admin user edit ("wpmem_admin_after_profile") * and the user profile edit ("wpmem_user_after_profile"). * * @since 2.9.3 * * @param int $user_id The user's ID. * @param array $wpmem_fields The WP-Members fields. */ do_action( 'wpmem_' . $display . '_after_profile', $user_id, $wpmem_fields ); ?>
' . $label . '', 'field' => $input, 'field_after' => '
base ) ? 'user' : 'admin'; if ( ! $user_id ) { $user_id = filter_var( wpmem_get( 'user_id', -1, 'request' ), FILTER_SANITIZE_NUMBER_INT ); if ( 1 > $user_id ) { // Still no user id? User cannot be updated. return; } } $wpmem_fields = ( 'admin' == $display ) ? wpmem_fields( 'admin_profile_update' ) : wpmem_fields( 'dashboard_profile_update' ); // Check for password field before exclusions, just in case we are activating a user (otherwise password is removed on user/admin profiles). $chk_pass = ( array_key_exists( 'password', $wpmem_fields ) && true === $wpmem_fields['password']['register'] ) ? true : false; $exclude = wpmem_get_excluded_meta( $display . '-profile' ); foreach ( $exclude as $excluded ) { unset( $wpmem_fields[ $excluded ] ); } // If tos is an active field, this is the dashboard profile, and user has current field value. if ( isset( $wpmem_fields['tos'] ) && 'user' == $display && get_user_meta( $user_id, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) { unset( $wpmem_fields['tos'] ); } /** * Fires before the user profile is updated. * * Action fires for the admin user edit ("wpmem_admin_pre_user_update") * and the user profile edit ("wpmem_user_pre_user_update"). * * @since 2.9.2 Added for admin profile update. * @since 3.1.9 Added for user profile update. * * @param int $user_id The user ID. * @param array $wpmem_fields Array of the custom fields. */ do_action( 'wpmem_' . $display . '_pre_user_update', $user_id, $wpmem_fields ); $fields = array(); foreach ( $wpmem_fields as $meta => $field ) { if ( ! $field['native'] && $field['type'] != 'password' && $field['type'] != 'checkbox' && $field['type'] != 'multiselect' && $field['type'] != 'multicheckbox' && $field['type'] != 'file' && $field['type'] != 'image' && $field['type'] != 'textarea' ) { ( isset( $_POST[ $meta ] ) && 'password' != $field['type'] ) ? $fields[ $meta ] = sanitize_text_field( $_POST[ $meta ] ) : false; // For user profile (not admin). $chk = false; if ( 'admin' != $display ) { // Check for required fields. if ( ! $field['required'] ) { $chk = 'ok'; } if ( $field['required'] && $_POST[ $meta ] != '' ) { $chk = 'ok'; } } } elseif ( $field['type'] == 'checkbox' ) { $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? sanitize_text_field( $_POST[ $meta ] ) : ''; } elseif ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) { $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? implode( $field['delimiter'], wp_unslash( $_POST[ $meta ] ) ) : ''; } elseif ( $field['type'] == 'textarea' ) { $fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? sanitize_textarea_field( $_POST[ $meta ] ) : ''; } } /** * Filter the submitted field values for backend profile update. * * Filters is applied for the admin user edit ("wpmem_admin_profile_update") * and the user profile edit ("wpmem_user_profile_update"). * * @since 2.8.2 Added for Admin profile update. * @since 3.1.9 Added for User profile update. * * @param array $fields An array of the posted form values. * @param int $user_id The ID of the user being updated. */ $fields = apply_filters( 'wpmem_' . $display . '_profile_update', $fields, $user_id ); // Handle meta update, skip excluded fields. foreach ( $fields as $key => $val ) { if ( ! in_array( $key, $exclude ) ) { if ( ( 'admin' != $display && 'ok' == $chk ) || 'admin' == $display ) { update_user_meta( $user_id, $key, $val ); } } } if ( ! empty( $_FILES ) ) { $wpmem->user->upload_user_files( $user_id, $wpmem->fields ); } if ( 'admin' == $display || current_user_can( 'edit_users' ) ) { if ( $wpmem->mod_reg == 1 ) { $wpmem_activate_user = ( isset( $_POST['activate_user'] ) == '' ) ? -1 : filter_var( $_POST['activate_user'], FILTER_SANITIZE_NUMBER_INT ); if ( $wpmem_activate_user == 1 ) { wpmem_activate_user( $user_id, $chk_pass ); } elseif ( $wpmem_activate_user == 0 ) { wpmem_deactivate_user( $user_id ); } } if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) { if ( function_exists( 'wpmem_a_extenduser' ) ) { wpmem_a_extend_user( $user_id ); } } if ( 1 == $wpmem->enable_products ) { // Update products. if ( isset( $_POST['_wpmem_membership_product'] ) ) { foreach ( $_POST['_wpmem_membership_product'] as $product_key => $product_value ) { // Sanitize. $product_key = sanitize_text_field( $product_key ); // Enable or Disable? if ( 'enable' == $product_value ) { // Does product require a role? if ( false !== $wpmem->membership->products[ $product_key ]['role'] ) { wpmem_update_user_role( $user_id, $wpmem->membership->products[ $product_key ]['role'], 'add' ); } // Do we need to set a specific date? if ( isset( $_POST[ '_wpmem_membership_product_expiration_' . $product_key ] ) ) { wpmem_set_user_product( $product_key, $user_id, sanitize_text_field( $_POST[ '_wpmem_membership_product_expiration_' . $product_key ] ) ); } else { wpmem_set_user_product( $product_key, $user_id ); } } if ( 'disable' == $product_value ) { $wpmem->user->remove_user_product( $product_key, $user_id ); } } } } } /** * Fires after the user profile is updated. * * Action fires for the admin user edit ("wpmem_admin_after_user_update") * and the user profile edit ("wpmem_user_after_user_update"). * * @since 2.9.2 * * @param int $user_id The user ID. */ do_action( 'wpmem_' . $display . '_after_user_update', $user_id ); return; } /** * Sets user profile update to multipart form data. * * If the fields array has a file or image field, this will echo the * necessary "multipart/form-data" enctype for the form tag. * * @since 3.1.8 (as wpmem_profile_multipart()). * @since 3.1.9 Moved to User Profile object. */ public static function add_multipart() { $has_file = false; foreach ( wpmem_fields() as $field ) { if ( $field['type'] == 'file' || $field['type'] == 'image' ) { $has_file = true; break; } } echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : ''; } /** * Adds user activation to the user profile. * * @since 3.1.1 * @since 3.2.0 Moved to WP_Members_User_Profile object * * @global object $wpmem * @param int $user_id */ public static function _show_activate( $user_id ) { global $wpmem; // See if reg is moderated, and if the user has been activated. if ( $wpmem->mod_reg == 1 ) { $user_active_flag = get_user_meta( $user_id, 'active', true ); switch( $user_active_flag ) { case '': $label = __( 'Activate this user?', 'wp-members' ); $action = 1; break; case 0: $label = __( 'Reactivate this user?', 'wp-members' ); $action = 1; break; case 1: $label = __( 'Deactivate this user?', 'wp-members' ); $action = 0; break; } ?> use_exp == 1 ) { if ( ( $wpmem->mod_reg == 1 && get_user_meta( $user_id, 'active', true ) == 1 ) || ( $wpmem->mod_reg != 1 ) ) { if ( function_exists( 'wpmem_a_extenduser' ) ) { wpmem_a_extenduser( $user_id ); } } } } /** * Adds user registration IP to the user profile. * * @since 3.1.1 * @since 3.2.0 Moved to WP_Members_User_Profile object * * @param int $user_id */ public static function _show_ip( $user_id ) { ?> user->get_user_products( $user_id ); ?> membership->products as $key => $value ) { $checked = ( $user_products && array_key_exists( $key, $user_products ) ) ? "checked" : ""; echo ""; echo ''; } ?>
' . $value['title'] . ' '; // If user has date, display that; otherwise placeholder $date_value = ( isset( $user_products[ $key ] ) ) ? $user_products[ $key ] : ""; $placeholder = ( ! isset( $user_products[ $key ] ) ) ? 'placeholder="' . __( 'Date', 'wp-members' ) . '" ' : ''; $product_date_field = ' '; if ( isset( $user_products[ $key ] ) ) { echo ''; if ( $user_products[ $key ] !== true ) { echo __( 'Expires:', 'wp-members' ); echo $product_date_field; } else { _e( 'Enabled', 'wp-members' ); } } else { if ( isset( $value['expires'] ) && ! empty( $value['expires'] ) ) { echo ''; echo __( 'Expires:', 'wp-members' ); echo $product_date_field; } else { echo " "; } } echo '
'; echo ''; foreach ( $tabs as $key => $value ) { echo '
'; echo ( isset( $value['content'] ) ) ? $value['content'] : ''; do_action( 'wpmem_user_profile_tabs_content', $key ); echo '
'; } echo ''; } } }