Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/user-registration/includes/class-ur-form-handler.php
+++ b/user-registration/includes/class-ur-form-handler.php
@@ -758,7 +758,7 @@
}
if ( $posted_fields['password_1'] !== $posted_fields['password_2'] ) {
- $err_msg = apply_filters( 'user_registration_reset_password_error_message', __( 'New password must not be same as old password.', 'user-registration' ) );
+ $err_msg = apply_filters( 'user_registration_reset_password_error_message', __( 'New passwords do not match.', 'user-registration' ) );
ur_add_notice( $err_msg, 'error' );
}
--- a/user-registration/includes/frontend/class-ur-frontend.php
+++ b/user-registration/includes/frontend/class-ur-frontend.php
@@ -662,6 +662,23 @@
$currency = empty( $currency ) ? get_option( 'user_registration_payment_currency', 'USD' ) : $currency;
$amount = $membership['billing_amount'] ?? '';
+ if ( isset( $membership['post_content']['type'] ) && 'subscription' === $membership['post_content']['type'] && isset( $membership['post_content']['amount'] ) ) {
+ $amount = (float) $membership['post_content']['amount'];
+
+ $subscription_last_order = $orders_repository->get_order_by_subscription( $membership['subscription_id'] );
+ if ( ! empty( $subscription_last_order['ID'] ) ) {
+ $tax_order_meta = $orders_repository->get_order_meta_by_order_id_and_meta_key( $subscription_last_order['ID'], 'tax_data' );
+ $tax_data = ! empty( $tax_order_meta['meta_value'] ) ? json_decode( $tax_order_meta['meta_value'], true ) : array();
+ $tax_rate = ! empty( $tax_data['tax_rate'] ) ? (float) $tax_data['tax_rate'] : 0;
+ $is_exclusive = ! empty( $tax_data['tax_calculation_method'] );
+
+ if ( $tax_rate > 0 && $is_exclusive ) {
+ $amount += round( $amount * $tax_rate / 100, 2 );
+ }
+ }
+
+ $amount = number_format( $amount, 2, '.', '' );
+ }
if ( isset( $membership['post_content']['type'] ) && 'subscription' === $membership['post_content']['type'] ) {
--- a/user-registration/includes/functions-ur-core.php
+++ b/user-registration/includes/functions-ur-core.php
@@ -1249,12 +1249,6 @@
$class_path = apply_filters( 'user_registration_form_field_' . $class_key . '_path', $class_path );
/* Backward Compat since 1.4.0 */
if ( null != $class_path && file_exists( $class_path ) ) {
- // Validate the resolved path to prevent directory traversal.
- $real_class_path = realpath( $class_path );
- $real_base_path = realpath( UR_FORM_PATH );
- if ( false === $real_class_path || false === $real_base_path || 0 !== strpos( $real_class_path, $real_base_path . DIRECTORY_SEPARATOR ) ) {
- return null;
- }
$class_name = 'UR_' . join( '_', array_map( 'ucwords', $exploded_class ) );
if ( ! class_exists( $class_name ) ) {
include_once $class_path;
--- a/user-registration/includes/functions-ur-page.php
+++ b/user-registration/includes/functions-ur-page.php
@@ -316,6 +316,8 @@
if ( ! is_user_logged_in() ) {
$customer_logout = get_option( 'user_registration_logout_endpoint', 'user-logout' );
+ $customer_logout = trim( $customer_logout, '/' );
+
if ( ! empty( $customer_logout ) && is_array( $items ) ) {
foreach ( $items as $key => $item ) {
if ( empty( $item->url ) ) {
--- a/user-registration/modules/functions-ur-modules.php
+++ b/user-registration/modules/functions-ur-modules.php
@@ -618,9 +618,13 @@
* @param array $args Arguments.
*/
function urm_get_form_user_payments( $args ) {
- $args['meta_key'] = 'ur_payment_status';
- $args['meta_compare'] = 'EXISTS';
- $args['meta_query']['relation'] = 'AND';
+ if ( ! isset( $args['meta_query'] ) ) {
+ $args['meta_query'] = array( 'relation' => 'AND' );
+ }
+ $args['meta_query'][] = array(
+ 'key' => 'ur_payment_status',
+ 'compare' => 'EXISTS',
+ );
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
--- a/user-registration/modules/membership/includes/Admin/Membership/Membership.php
+++ b/user-registration/modules/membership/includes/Admin/Membership/Membership.php
@@ -513,11 +513,13 @@
$group_id = $membership_group['ID'] ?? 0;
}
- foreach ( $memberships as $key => $_membership ) {
- $current_membership_group = $membership_group_repository->get_membership_group_by_membership_id( $_membership['ID'] );
+ if ( ur_check_module_activation( 'membership-groups' ) ) {
+ foreach ( $memberships as $key => $_membership ) {
+ $current_membership_group = $membership_group_repository->get_membership_group_by_membership_id( $_membership['ID'] );
- if ( ! empty( $current_membership_group ) && absint( $current_membership_group['ID'] ) !== $group_id ) {
- unset( $memberships[ $key ] );
+ if ( ! empty( $current_membership_group ) && absint( $current_membership_group['ID'] ) !== $group_id ) {
+ unset( $memberships[ $key ] );
+ }
}
}
--- a/user-registration/modules/membership/includes/Admin/Services/Paypal/PaypalService.php
+++ b/user-registration/modules/membership/includes/Admin/Services/Paypal/PaypalService.php
@@ -932,7 +932,7 @@
curl_close( $ch );
return array(
- 'access_token' => $result->access_token,
+ 'access_token' => isset( $result->access_token ) ? $result->access_token : null,
'status_code' => $status_code,
);
} catch ( Exception $e ) {
--- a/user-registration/modules/membership/includes/Admin/Services/Stripe/StripeService.php
+++ b/user-registration/modules/membership/includes/Admin/Services/Stripe/StripeService.php
@@ -846,9 +846,6 @@
$payment_status = $intent->status;
$latest_order = $this->orders_repository->get_order_by_transaction_id( $intent->id );
- if ( empty( $latest_order ) ) {
- $latest_order = $this->members_orders_repository->get_member_orders( $member_id );
- }
$latest_order = is_array( $latest_order ) ? $latest_order : ( $latest_order ? (array) $latest_order : array() );
if ( empty( $latest_order ) || (int) $member_id !== (int) $latest_order['user_id'] ) {
--- a/user-registration/modules/paypal/class-ur-paypal-module.php
+++ b/user-registration/modules/paypal/class-ur-paypal-module.php
@@ -51,7 +51,7 @@
$paypal_enabled = get_option( 'user_registration_paypal_enabled', '' );
if ( false === get_option( 'urm_global_paypal_settings_migrated_', false ) ) {
- //runs for backward compatibility, could be removed in future versions.
+ // runs for backward compatibility, could be removed in future versions.
if ( 'test' === $paypal_mode ) {
$test_admin_email = get_option( 'admin_email', '' );
$test_client_id = get_option( 'user_registration_global_paypal_client_id', '' );
@@ -207,7 +207,7 @@
if ( isset( $form_data['user_registration_paypal_enabled'] ) && ! $form_data['user_registration_paypal_enabled'] ) {
return $response;
}
- //check if any value has changed
+ // check if any value has changed
foreach ( $form_data as $k => $data ) {
$last_data = get_option( $k );
if ( $last_data !== $data ) {
@@ -307,9 +307,9 @@
ur_get_logger()->info(
'[PayPal][Webhook] Registration triggered.' . "n" . wp_json_encode(
array(
- 'trigger' => $changed ? 'credentials_changed' : 'webhook_id_missing',
- 'mode' => $form_data['user_registration_global_paypal_mode'],
- 'webhook_stored' => $webhook_stored,
+ 'trigger' => $changed ? 'credentials_changed' : 'webhook_id_missing',
+ 'mode' => $form_data['user_registration_global_paypal_mode'],
+ 'webhook_stored' => $webhook_stored,
),
JSON_PRETTY_PRINT
),
@@ -323,8 +323,8 @@
ur_get_logger()->info(
'[PayPal][Webhook] Webhook ID saved to options.' . "n" . wp_json_encode(
array(
- 'webhook_id' => $webhook_result,
- 'option_key' => 'user_registration_global_paypal_' . $mode . '_webhook_id',
+ 'webhook_id' => $webhook_result,
+ 'option_key' => 'user_registration_global_paypal_' . $mode . '_webhook_id',
),
JSON_PRETTY_PRINT
),
--- a/user-registration/user-registration.php
+++ b/user-registration/user-registration.php
@@ -4,7 +4,7 @@
* Plugin Name: User Registration & Membership
* Plugin URI: https://wpuserregistration.com/
* Description: The most flexible User Registration and Membership plugin for WordPress.
- * Version: 5.2.0
+ * Version: 5.2.1
* Author: WPEverest
* Author URI: https://wpuserregistration.com
* Text Domain: user-registration
@@ -37,7 +37,7 @@
*
* @var string
*/
- public $version = '5.2.0';
+ public $version = '5.2.1';
/**
* Session instance.
@@ -225,7 +225,7 @@
$this->define( 'UR_ASSET_PATH', plugins_url( 'assets/', UR_PLUGIN_FILE ) );
$this->define( 'UR_FORM_PATH', UR_ABSPATH . 'includes' . UR_DS . 'form' . UR_DS );
$this->define( 'UR_SESSION_CACHE_GROUP', 'ur_session_id' );
- $this->define( 'UR_PRO_ACTIVE', false );
+ $this->define( 'UR_PRO_ACTIVE', true );
$this->define( 'UR_DEV', false );
}