ID ); ?>

%2$s', esc_url( add_query_arg( array( 'page' => 'pmpro-member', 'user_id' => $user->ID, 'pmpro_member_edit_panel' => 'memberships' ), admin_url( 'admin.php' ) ) ), esc_html__( 'single member dashboard', 'paid-memberships-pro' ) ) ) ); ?>

ID, $user_level->ID ); ?>
name ); ?> enddate; if ( empty( $enddate_to_show ) ) { esc_html_e( 'Never', 'paid-memberships-pro' ); } else { echo esc_html( sprintf( // translators: %1$s is the date and %2$s is the time. __( '%1$s at %2$s', 'paid-memberships-pro' ), esc_html( date_i18n( get_option( 'date_format'), $enddate_to_show ) ), esc_html( date_i18n( get_option( 'time_format'), $enddate_to_show ) ) ) ); } ?> ID, $shown_level->id ); if ( ! empty( $subscriptions ) ) { // If the user has more than 1 subscription, show a warning message. if ( count( $subscriptions ) > 1 ) { ?>

%2$s', esc_url( add_query_arg( array( 'page' => 'pmpro-member', 'user_id' => $user->ID, 'pmpro_member_edit_panel' => 'subscriptions' ), admin_url( 'admin.php' ) ) ), esc_html__( 'View Subscriptions', 'paid-memberships-pro' ) ) ) ); ?>

get_cost_text() ); } else { ?>

membership_level = pmpro_getMembershipLevelForUser($user->ID); $groups = pmpro_get_level_groups_in_order(); if( empty ( $groups ) ) { return ''; } // Get all membership levels for this user. $user_levels = pmpro_getMembershipLevelsForUser($user->ID); ?>

id ); if ( empty( $levels_in_group ) ) { continue; } // Get all the levels in this group that the user has. $user_level_ids_in_group = array(); $user_levels_in_group = array(); foreach ( $levels_in_group as $level ) { foreach ( $user_levels as $user_level ) { if ( $level->id === $user_level->id ) { $user_level_ids_in_group[] = $level->id; $user_levels_in_group[ $level->id ] = $user_level; } } } // Set up the for this group. ?> ID, true ); if( !empty( $tospage_id ) || !empty( $consent_log ) ) { ?>
name ); ?> allow_multiple_selections ) ) { // If the user somehow has multiple levels from this group, show a warning that non-selected levels will be removed on save. if ( count( $user_level_ids_in_group ) > 1 ) { ?>


enddate ); $enddate_to_show = ! empty( $shown_level->enddate ) ? date( 'Y-m-d H:i', $shown_level->enddate ) : $enddate_to_show; $shown_level_name_prefix = 'pmpro_membership_levels[' . $shown_level->id . ']'; } ?>

> /> >

ID, $shown_level->id ); if ( ! empty( $subscriptions ) ) { $subscription = $subscriptions[0]; ?>

get_cost_text() ); ?>

1 ) { ?>



getLastMemberOrder( $user->ID, array( 'success', 'refunded' ), $shown_level->id ); if ( pmpro_allowed_refunds( $last_order ) ) { ?> id . ']'; ?> ID, $level->id ); if ( ! empty( $subscriptions ) && ( empty( $shown_level ) || $shown_level->id != $level->id ) ) { ?>

name ) ); ?>


id, $user_level_ids_in_group ); $name_prefix = 'pmpro_membership_levels[' . $level->id . ']'; ?>
id ] ) ) { $has_enddate = ! empty( $user_levels_in_group[ $level->id ]->enddate ); $enddate_to_show = $has_enddate ? date( 'Y-m-d H:i', $user_levels_in_group[ $level->id ]->enddate ) : $enddate_to_show; } ?> /> > ID, $level->id ); if ( ! empty( $subscriptions ) ) { // If the user has more than 1 subscription, show a warning message. if ( count( $subscriptions ) > 1 ) { ?>


get_cost_text() ); ?>


getLastMemberOrder( $user->ID, array( 'success', 'refunded' ), $level->id ); if ( pmpro_allowed_refunds( $last_order ) ) { ?> ID, $level->id ); if ( ! empty( $subscriptions ) ) { ?>


and
. ?>
ID ) : intval( $_REQUEST['user_id'] ); $membership_level_capability = apply_filters( 'pmpro_edit_member_capability', 'pmpro_edit_members' ); if ( ! current_user_can( $membership_level_capability ) ) { return false; } // Get the user's current membership levels. $user_levels = pmpro_getMembershipLevelsForUser( $user_id ); $user_level_ids = wp_list_pluck( $user_levels, 'id' ); // Set up some arrays to hold level changes. $levels_to_remove = array(); // Associative array of IDs and whether to cancel the associated subscription. $levels_to_add = array(); // Array of IDs. $levels_to_update = array(); // Associative array of IDs and expiration dates. // Get the data submitted from the profile. if ( empty ( $_REQUEST['pmpro_membership_levels'] ) ) { return false; } // Key is level ID, value is array of user selections. Sanitize input. $submitted_levels = array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized foreach( $_REQUEST['pmpro_membership_levels'] as $key => $values ) { $key = intval( $key ); $values = array_map( 'sanitize_text_field', $values ); $submitted_levels[$key] = $values; } $submitted_levels = $_REQUEST['pmpro_membership_levels']; // Loop through the submitted levels. foreach ( $submitted_levels as $submitted_level => $submitted_level_data ) { // Get the data for the level. $selected = ! empty( $submitted_level_data['has_level'] ); $expiration = ( ! empty( $submitted_level_data['expires'] ) && ! empty( $submitted_level_data['expiration'] ) ) ? $submitted_level_data['expiration'] : null; if ( ! $selected && in_array( $submitted_level, $user_level_ids ) ) { // Level was removed. $levels_to_remove[ $submitted_level ] = empty( $submitted_level_data['subscription_action'] ) || 'cancel' === $submitted_level_data['subscription_action']; // Refund the order if needed. if ( ! empty( $submitted_level_data['refund'] ) ) { $last_order = new MemberOrder(); $last_order->getLastMemberOrder( $user_id, array( 'success', 'refunded' ), $submitted_level ); if ( ! empty( $last_order ) ) { pmpro_refund_order( $last_order ); } } } elseif ( $selected && ! in_array( $submitted_level, $user_level_ids ) ) { // Level was added. $levels_to_add[] = $submitted_level; // We may also need to update the expiration date. if ( ! empty( $expiration ) ) { $levels_to_update[ $submitted_level ] = $expiration; } } elseif ( $selected && in_array( $submitted_level, $user_level_ids ) ) { // User may have changed the expiration date. Let's check. $current_expiration = pmpro_getMembershipLevelForUser( $user_id, $submitted_level )->enddate; if ( $current_expiration != strtotime( $expiration ) ) { // Update the expiration date. $levels_to_update[ $submitted_level ] = $expiration; } } } // Finally, we need to execute the level changes. // Remove levels. foreach ( $levels_to_remove as $level_to_remove => $cancel_subscription ) { if ( empty( $cancel_subscription ) ) { // Cancel the subscription. add_filter( 'pmpro_cancel_previous_subscriptions', 'pmpro_cancel_previous_subscriptions_false' ); } pmpro_cancelMembershipLevel( $level_to_remove, $user_id, 'admin_changed' ); remove_filter( 'pmpro_cancel_previous_subscriptions', 'pmpro_cancel_previous_subscriptions_false' ); } // Add levels. foreach ( $levels_to_add as $level_to_add ) { pmpro_changeMembershipLevel( $level_to_add, $user_id, 'admin_changed' ); } // Update levels. foreach ( $levels_to_update as $level_to_update => $expiration ) { if ( empty( $expiration ) ) { // Set level to not expire. $wpdb->update( $wpdb->pmpro_memberships_users, array( 'enddate' => NULL ), array( 'status' => 'active', 'membership_id' => $level_to_update, 'user_id' => $user_id ), array( NULL ), array( '%s', '%d', '%d' ) ); } else { // Set expiration date for level. $wpdb->update( $wpdb->pmpro_memberships_users, array( 'enddate' => date( 'Y-m-d H:i:s', strtotime( $expiration ) ) ), array( 'status' => 'active', 'membership_id' => $level_to_update, 'user_id' => $user_id ), array( '%s' ), array( '%s', '%d', '%d' ) ); } } // If any level changes were made and the admin wants to send an email, do it. if ( ! empty( $levels_to_add ) || ! empty( $levels_to_remove ) || ! empty( $levels_to_update ) ) { if ( ! empty( $_REQUEST['pmpro_send_change_email'] ) ) { $edited_user = get_userdata( $user_id ); // Send an email to the user. $myemail = new PMProEmail(); $myemail->sendAdminChangeEmail( $edited_user ); // Send an email to the admin. $myemail = new PMProEmail(); $myemail->sendAdminChangeAdminEmail( $edited_user ); } } } /** * Add the history view to the user profile * * @deprecated 3.0 Use the single member dashboard. */ function pmpro_membership_history_profile_fields( $user ) { global $current_user; _deprecated_function( __FUNCTION__, '3.0' ); $membership_level_capability = apply_filters( 'pmpro_edit_member_capability', 'pmpro_edit_members' ); if ( ! current_user_can( $membership_level_capability ) ) { return false; } global $wpdb; //Show all invoices for user $invoices = $wpdb->get_results( $wpdb->prepare( "SELECT mo.*, du.code_id as code_id FROM $wpdb->pmpro_membership_orders mo LEFT JOIN $wpdb->pmpro_discount_codes_uses du ON mo.id = du.order_id WHERE mo.user_id = %d ORDER BY mo.timestamp DESC", $user->ID ) ); $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->pmpro_subscriptions WHERE user_id = %d ORDER BY startdate DESC", $user->ID ) ); $levelshistory = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->pmpro_memberships_users WHERE user_id = %s ORDER BY id DESC", $user->ID ) ); $totalvalue = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(total) FROM $wpdb->pmpro_membership_orders WHERE user_id = %d AND status NOT IN('token','review','pending','error','refunded')", $user->ID ) ); if ( $invoices || $subscriptions || $levelshistory ) { ?>


2 ) { $invoices_classes[] = "pmpro_scrollable"; } $invoice_class = implode( ' ', array_unique( $invoices_classes ) ); ?>
membership_id ); ?>
timestamp ) ) ) ), esc_html( date_i18n( get_option( 'time_format' ), strtotime( get_date_from_gmt( $invoice->timestamp ) ) ) ) ) ); ?> code ); ?>
id ) ); ?> | | |
name ); } elseif ( $invoice->membership_id > 0 ) { ?> [] total ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> code_id ) ) { esc_html_e( '—', 'paid-memberships-pro' ); } else { $discountQuery = $wpdb->prepare( "SELECT c.code FROM $wpdb->pmpro_discount_codes c WHERE c.id = %d LIMIT 1", $invoice->code_id ); $discount_code = $wpdb->get_row( $discountQuery ); echo ''. esc_attr( $discount_code->code ) . ''; } ?> status ) ) { esc_html_e( '—', 'paid-memberships-pro' ); } else { ?> status, array( 'success', 'cancelled' ) ) ) { esc_html_e( 'Paid', 'paid-memberships-pro' ); } else { echo esc_html( ucwords( $invoice->status ) ); } ?>
2 ) { $subscriptions_classes[] = "pmpro_scrollable"; } $subscriptions_class = implode( ' ', array_unique( $subscriptions_classes ) ); ?> 4 ) { $levelshistory_classes[] = "pmpro_scrollable"; } $levelshistory_class = implode( ' ', array_unique( $levelshistory_classes ) ); ?> base == 'user-edit' || $screen->base == 'profile' ) { // Require the core Paid Memberships Pro Admin Functions. if ( defined( 'PMPRO_DIR' ) ) { require_once( PMPRO_DIR . '/adminpages/functions.php' ); } // Load the email order modal. if ( function_exists( 'pmpro_add_email_order_modal' ) ) { pmpro_add_email_order_modal(); } } } /** * Display a frontend Member Profile Edit form and allow user to edit specific fields. * * @since 2.3 */ function pmpro_member_profile_edit_form() { global $current_user; if ( ! is_user_logged_in() ) { echo '
' . esc_html__( 'Log in to edit your profile.', 'paid-memberships-pro' ) . '
'; return; } // Saving profile updates. if ( isset( $_POST['action'] ) && $_POST['action'] == 'update-profile' && $current_user->ID == $_POST['user_id'] && wp_verify_nonce( sanitize_key( $_POST['update_user_nonce'] ), 'update-user_' . $current_user->ID ) ) { $update = true; $user = new stdClass; $user->ID = intval( $_POST[ 'user_id' ] ); do_action( 'pmpro_personal_options_update', $user->ID ); } else { $update = false; } if ( $update ) { $errors = array(); // Get all values from the $_POST, sanitize them, and build the $user object. if ( isset( $_POST['user_email'] ) ) { $user->user_email = sanitize_text_field( wp_unslash( $_POST['user_email'] ) ); } if ( isset( $_POST['first_name'] ) ) { $user->first_name = sanitize_text_field( $_POST['first_name'] ); } if ( isset( $_POST['last_name'] ) ) { $user->last_name = sanitize_text_field( $_POST['last_name'] ); } if ( isset( $_POST['display_name'] ) ) { $user->display_name = sanitize_text_field( $_POST['display_name'] ); $user->nickname = $user->display_name; } // Validate display name. if ( empty( $user->display_name ) ) { $errors[] = __( 'Please enter a display name.', 'paid-memberships-pro' ); } // Don't allow admins to change their email address. if ( current_user_can( 'manage_options' ) ) { $user->user_email = $current_user->user_email; } // Validate email address. if ( empty( $user->user_email ) ) { $errors[] = __( 'Please enter an email address.', 'paid-memberships-pro' ); } elseif ( ! is_email( $user->user_email ) ) { $errors[] = __( 'The email address isn’t correct.', 'paid-memberships-pro' ); } else { $owner_id = email_exists( $user->user_email ); if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) { $errors[] = __( 'This email is already registered, please choose another one.', 'paid-memberships-pro' ); } } /** * Fires before member profile update errors are returned. * * @param $errors WP_Error object (passed by reference). * @param $update Whether this is a user update. * @param $user User object (passed by reference). */ do_action_ref_array( 'pmpro_user_profile_update_errors', array( &$errors, $update, &$user ) ); // Show error messages. if ( ! empty( $errors ) ) { ?>
> ID, 'update_user_nonce' ); ?> __( 'First Name', 'paid-memberships-pro' ), 'last_name' => __( 'Last Name', 'paid-memberships-pro' ), 'display_name' => __( 'Display name publicly as', 'paid-memberships-pro' ), 'user_email' => __( 'Email', 'paid-memberships-pro' ), ) ); ?>
$label ) { ?>


ID != $_POST['user_id'] ) { return; } // Check the nonce. if ( ! wp_verify_nonce( sanitize_key( $_POST['change_password_user_nonce'] ), 'change-password-user_' . $current_user->ID ) ) { return; } // Get all password values from the $_POST. if ( ! empty( $_POST['password_current'] ) ) { $password_current = sanitize_text_field( $_POST['password_current'] ); } else { $password_current = ''; } if ( ! empty( $_POST['pass1'] ) ) { $pass1 = sanitize_text_field( $_POST['pass1'] ); } else { $pass1 = ''; } if ( ! empty( $_POST['pass2'] ) ) { $pass2 = sanitize_text_field( $_POST['pass2'] ); } else { $pass2 = ''; } // Check that all password information is correct. $error = false; if ( isset( $password_current ) && ( empty( $pass1 ) || empty( $pass2 ) ) ) { $error = __( 'Please complete all fields.', 'paid-memberships-pro' ); } elseif ( ! empty( $pass1 ) && empty( $password_current ) ) { $error = __( 'Please enter your current password.', 'paid-memberships-pro' ); } elseif ( ( ! empty( $pass1 ) || ! empty( $pass2 ) ) && $pass1 !== $pass2 ) { $error = __( 'New passwords do not match.', 'paid-memberships-pro' ); } elseif ( ! empty( $pass1 ) && ! wp_check_password( $password_current, $current_user->user_pass, $current_user->ID ) ) { $error = __( 'Your current password is incorrect.', 'paid-memberships-pro' ); } // Change the password. if ( ! empty( $pass1 ) && empty( $error ) ) { wp_set_password( $pass1, $current_user->ID ); //setting some cookies wp_set_current_user( $current_user->ID, $current_user->user_login ); wp_set_auth_cookie( $current_user->ID, true, apply_filters( 'pmpro_checkout_signon_secure', force_ssl_admin() ) ); pmpro_setMessage( __( 'Your password has been updated.', 'paid-memberships-pro' ), 'pmpro_success' ); } else { pmpro_setMessage( $error, 'pmpro_error' ); } } add_action( 'init', 'pmpro_change_password_process' ); /** * Display a frontend Change Password form and allow user to edit their password when logged in. * * @since 2.3 */ function pmpro_change_password_form() { global $current_user, $pmpro_msg, $pmpro_msgt; ?>

ID, 'change_password_user_nonce' ); ?>
*
*

*