Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-manage.php
+++ b/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-manage.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin controllers
- *
- * Plugin Memberships Manage Controller
- *
- * @author WC Lovers
- * @package wcfmvm/controllers
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Memberships_Manage_Controller {
@@ -36,76 +36,76 @@
$membership_status = 'publish';
- // Creating new membership
+
$new_membership = array(
'post_title' => wc_clean( $wcfm_membership_manager_form_data['title'] ),
'post_status' => $membership_status,
'post_type' => 'wcfm_memberships',
'post_excerpt' => $wcfm_membership_manager_form_data['excerpt'],
'post_author' => $current_user_id
- //'post_name' => sanitize_title($wcfm_membership_manager_form_data['title'])
+
);
if(isset($wcfm_membership_manager_form_data['membership_id']) && $wcfm_membership_manager_form_data['membership_id'] == 0) {
$new_membership_id = wp_insert_post( $new_membership, true );
- } else { // For Update
+ } else {
$is_update = true;
$new_membership['ID'] = $wcfm_membership_manager_form_data['membership_id'];
$new_membership_id = wp_update_post( $new_membership, true );
}
if(!is_wp_error($new_membership_id)) {
- // For Update
+
if($is_update) {
$new_membership_id = $wcfm_membership_manager_form_data['membership_id'];
- // Remove Membership from old Vendors
- /*if( $is_marketplace ) {
- $old_membership_vendors = (array) get_post_meta( $new_membership_id, '_membership_vendors', true );
- if( !empty( $old_membership_vendors ) ) {
- foreach( $old_membership_vendors as $old_membership_vendor ) {
- $wcfm_vendor_memberships = (array) get_user_meta( $old_membership_vendor, '_wcfm_vendor_membership', true );
- if( !empty( $wcfm_vendor_memberships ) ) {
- if( ( $key = array_search( $new_membership_id, $wcfm_vendor_memberships ) ) !== false ) {
- unset( $wcfm_vendor_memberships[$key] );
- }
- update_user_meta( $old_membership_vendor, '_wcfm_vendor_membership', $wcfm_vendor_memberships );
- }
- }
- }
- }*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
- // Update Membership Status
+
if( isset( $wcfm_membership_manager_form_data['is_wcfm_membership_disable'] ) ) {
update_post_meta( $new_membership_id, 'is_wcfm_membership_disable', 'yes' );
} else {
delete_post_meta( $new_membership_id, 'is_wcfm_membership_disable' );
}
- // Hide from Membership Plan Table
+
if( isset( $wcfm_membership_manager_form_data['is_wcfm_membership_plan_disable'] ) ) {
update_post_meta( $new_membership_id, 'is_wcfm_membership_plan_disable', 'yes' );
} else {
delete_post_meta( $new_membership_id, 'is_wcfm_membership_plan_disable' );
}
- // Update Subscribe Button
+
if( isset( $wcfm_membership_manager_form_data['subscribe_button_label'] ) ) {
update_post_meta( $new_membership_id, 'subscribe_button_label', $wcfm_membership_manager_form_data['subscribe_button_label'] );
} else {
update_post_meta( $new_membership_id, 'subscribe_button_label', __( "Subscribe Now", 'wc-multivendor-membership' ) );
}
- // Update Membership Feature
+
if( isset( $wcfm_membership_manager_form_data['features'] ) ) {
update_post_meta( $new_membership_id, 'features', $wcfm_membership_manager_form_data['features'] );
} else {
update_post_meta( $new_membership_id, 'features', array() );
}
- // Manage Subscription Pay Mode
+
if( isset( $wcfm_membership_manager_form_data['subscription'] ) && isset( $wcfm_membership_manager_form_data['subscription']['subscription_pay_mode'] ) ) {
$subscription_pay_mode = $wcfm_membership_manager_form_data['subscription']['subscription_pay_mode'];
@@ -134,17 +134,17 @@
update_option( 'wcfm_subcription_products', $wcfm_subcription_products );
}
- // Update Membership Subscription
+
if( isset( $wcfm_membership_manager_form_data['subscription'] ) ) {
update_post_meta( $new_membership_id, 'subscription', $wcfm_membership_manager_form_data['subscription'] );
} else {
update_post_meta( $new_membership_id, 'subscription', array() );
}
- // Membership Users
+
$membership_users = (array) get_post_meta( $new_membership_id, 'membership_users', true );
- // Correct Membership User Count
+
if( !empty( $membership_users ) && is_array( $membership_users ) ) {
foreach( $membership_users as $member_id ) {
$vendor_user = get_userdata( $member_id );
@@ -161,11 +161,11 @@
update_post_meta( $new_membership_id, 'membership_users', $membership_users );
}
- // Update Membership Commission
+
if( isset( $wcfm_membership_manager_form_data['commission'] ) ) {
$is_marketplace = wcfm_is_marketplace();
- // Update vendor specific commission setting by membership commission rulee, except WCFM Marketplace vendors
+
if( $is_marketplace != 'wcfmmarketplace' ) {
$old_commission = (array) get_post_meta( $new_membership_id, 'commission', true );
$old_commission_type = isset( $old_commission['type'] ) ? $old_commission['type'] : '';
@@ -213,9 +213,9 @@
$vendor_data['commission'] = $commission_value;
update_term_meta( $vendor_id, 'vendor_data', $vendor_data );
} elseif( $is_marketplace == 'wcfmmarketplace' ) {
- //$wcfmmp_profile_settings = get_user_meta( $member_id, 'wcfmmp_profile_settings', true );
- //$wcfmmp_profile_settings['commission'] = $wcfm_membership_manager_form_data['commission'];
- //update_user_meta( $member_id, 'wcfmmp_profile_settings', $wcfmmp_profile_settings );
+
+
+
}
}
}
@@ -227,7 +227,7 @@
update_post_meta( $new_membership_id, 'commission', array() );
}
- // Update Membership Group
+
if( isset( $wcfm_membership_manager_form_data['associated_group'] ) && !empty( $wcfm_membership_manager_form_data['associated_group'] ) ) {
$old_associated_group = get_post_meta( $new_membership_id, 'associated_group', true );
$old_group_vendors = array();
@@ -263,7 +263,7 @@
update_post_meta( $associated_group, '_group_vendors', $group_vendors );
}
- // Correct Associate Group Vendors Count
+
$associated_group_vendors = get_post_meta( $associated_group, '_group_vendors', true );
if( !empty( $associated_group_vendors ) && is_array( $associated_group_vendors ) ) {
foreach( $associated_group_vendors as $member_id ) {
@@ -285,39 +285,39 @@
update_post_meta( $new_membership_id, 'associated_group', '' );
}
- // Memvership Subscription Required Admin Approval
+
if( isset( $wcfm_membership_manager_form_data['required_approval'] ) ) {
update_post_meta( $new_membership_id, 'required_approval', 'yes' );
} else {
update_post_meta( $new_membership_id, 'required_approval', 'no' );
}
- // Memvership Application Reject Rule
+
if( isset( $wcfm_membership_manager_form_data['vendor_reject_rule'] ) ) {
update_post_meta( $new_membership_id, 'vendor_reject_rule', $wcfm_membership_manager_form_data['vendor_reject_rule'] );
}
- // Thank You page content
+
if( isset( $_POST['free_thankyou_content'] ) ) {
wcfm_update_post_meta( $new_membership_id, 'free_thankyou_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['free_thankyou_content'], ENT_QUOTES, 'UTF-8' ) ), 'post' ) );
}
- // On Approval Thank You page content
+
if( isset( $_POST['subscription_thankyou_content'] ) ) {
wcfm_update_post_meta( $new_membership_id, 'subscription_thankyou_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['subscription_thankyou_content'], ENT_QUOTES, 'UTF-8' ) ), 'post' ) );
}
- // Welcome Email Subject
+
if( isset( $wcfm_membership_manager_form_data['subscription_welcome_email_subject'] ) ) {
wcfm_update_post_meta( $new_membership_id, 'subscription_welcome_email_subject', $wcfm_membership_manager_form_data['subscription_welcome_email_subject'] );
}
- // Welcome Email Content
+
if( isset( $_POST['subscription_welcome_email_content'] ) ) {
wcfm_update_post_meta( $new_membership_id, 'subscription_welcome_email_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['subscription_welcome_email_content'], ENT_QUOTES, 'UTF-8' ) ), 'post' ) );
}
- // Hook for additional processing
+
do_action( 'wcfm_memberships_manage_from_process', $new_membership_id, $wcfm_membership_manager_form_data );
echo '{"status": true, "message": "' . esc_html( $wcfm_membership_messages['membership_saved'] ) . '", "id": ' . esc_attr($new_membership_id) . '}';
--- a/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-payment.php
+++ b/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-payment.php
@@ -1,14 +1,14 @@
<?php
-/**
- * WCFM plugin controllers
- *
- * Plugin Memberships Payment Controller
- *
- * @author WC Lovers
- * @package wcfmvm/controllers
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Memberships_Payment_Controller {
@@ -41,27 +41,33 @@
$paymode = wc_clean($_POST['paymode']);
if ($wcfm_membership) {
+
+ if ( ( '-1' != $wcfm_membership ) && !wcfm_is_selectable_membership( $wcfm_membership ) ) {
+ echo '{"status": false, "message": "' . esc_html($wcfm_membership_payment_messages['subscription_failed']) . '"}';
+ die;
+ }
+
$subscription = (array) get_post_meta($wcfm_membership, 'subscription', true);
$is_free = isset($subscription['is_free']);
- /**
- * This controller finalises the subscription and registers the vendor WITHOUT
- * contacting any payment gateway, so it must only ever complete:
- *
- * - Free memberships (nothing is due), or
- * - Paid memberships paid with an *offline* method the admin has enabled
- * (e.g. Bank Transfer) that is reconciled outside the site.
- *
- * Online gateways (PayPal, Stripe) must NOT be completed here -- they are
- * finalised only after the gateway returns a verified IPN (see
- * ipn/wcfmvm-handle-pp-ipn.php and ipn/wcfmvm-handle-stripe-sca-*-ipn.php).
- * Completing them here would let a member activate a paid vendor membership
- * without ever paying (CVE-2026-12967). The paymode is also validated against
- * the admin allow-list so a disabled method cannot be forced via a direct
- * request (Broken Access Control).
- */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
if ($is_free) {
- // Free plan: payment mode is irrelevant, normalise it.
+
$paymode = 'free';
} else {
$enabled_payment_methods = get_wcfm_membership_enabled_payment_methods();
@@ -83,7 +89,7 @@
$WCFMvm->send_approval_reminder_admin($member_id);
}
- // Reset Membership Session
+
if (WC()->session && WC()->session->get('wcfm_membership')) {
WC()->session->__unset('wcfm_membership');
}
--- a/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-registration.php
+++ b/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-registration.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin controllers
- *
- * Plugin Memberships Registration Controller
- *
- * @author WC Lovers
- * @package wcfmvm/controllers
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Memberships_Registration_Controller {
@@ -30,7 +30,7 @@
$wcfm_membership = '';
$subscription_pay_mode = 'by_wcfm';
- // Google reCaptcha support
+
if (apply_filters('wcfm_is_allow_registration_recaptcha', true)) {
if (function_exists('gglcptch_init')) {
if (isset($wcfm_membership_registration_form_data['g-recaptcha-response']) && !empty($wcfm_membership_registration_form_data['g-recaptcha-response'])) {
@@ -38,7 +38,7 @@
}
$check_result = apply_filters('gglcptch_verify_recaptcha', true, 'string', 'wcfm_registration_form');
if (true === $check_result) {
- /* do necessary action */
+
} else {
echo '{"status": false, "message": "' . esc_html($check_result) . '"}';
die;
@@ -46,7 +46,7 @@
} elseif (function_exists('anr_captcha_form_field')) {
$check_result = anr_verify_captcha($wcfm_membership_registration_form_data['g-recaptcha-response']);
if (true === $check_result) {
- /* do necessary action */
+
} else {
echo '{"status": false, "message": "' . esc_html__('Captcha failed, please try again.', 'wc-frontend-manager') . '"}';
die;
@@ -81,7 +81,7 @@
die;
}
- // WCFM form custom validation filter
+
$custom_validation_results = apply_filters('wcfm_form_custom_validation', $wcfm_membership_registration_form_data, 'vendor_registration');
if (isset($custom_validation_results['has_error']) && !empty($custom_validation_results['has_error'])) {
$custom_validation_error = __('There has some error in submitted data.', 'wc-frontend-manager');
@@ -92,7 +92,16 @@
die;
}
- // Handle File Uploads - 2.3.0
+
+ if (WC()->session && WC()->session->get('wcfm_membership')) {
+ $chosen_membership = WC()->session->get('wcfm_membership');
+ if (('-1' != $chosen_membership) && !wcfm_is_selectable_membership($chosen_membership)) {
+ echo '{"status": false, "message": "' . esc_html__('The selected membership plan is no longer available. Please choose another plan.', 'wc-multivendor-membership') . '"}';
+ die;
+ }
+ }
+
+
$files_data = array();
if (!empty($_FILES)) {
foreach ($_FILES as $file_key => $file) {
@@ -153,7 +162,7 @@
$email_verification = isset($membership_type_settings['email_verification']) ? 'yes' : '';
$sms_verification = isset($membership_type_settings['sms_verification']) ? 'yes' : '';
- // EMAIL Verification
+
if (apply_filters('wcfm_is_allow_email_verification', true)) {
$email_verified = false;
if (!$has_error) {
@@ -192,7 +201,7 @@
}
}
- // SMS Verification - 2.3.0
+
if (apply_filters('wcfm_is_allow_sms_verification', true) && function_exists('wcfm_is_store_page')) {
$sms_verified = false;
if (!$has_error) {
@@ -231,7 +240,7 @@
}
}
- // WCFM Marketplace Store Name Unique Check
+
$store_slug = '';
if (!$has_error && !wcfm_is_vendor() && isset($wcfm_membership_registration_form_data['store_name']) && !empty($wcfm_membership_registration_form_data['store_name'])) {
$store_slug = sanitize_title(wc_clean($wcfm_membership_registration_form_data['store_name']));
@@ -291,54 +300,54 @@
if (!$member_id || is_wp_error($member_id)) {
$has_error = true;
} else {
- /*if( !$is_update ) {
- if( !defined( 'DOING_WCFM_EMAIL' ) )
- define( 'DOING_WCFM_EMAIL', true );
-
- // Sending Mail to new user
- $mail_to = $wcfm_membership_registration_form_data['user_email'];
- $new_account_mail_subject = "{site_name}: New Account Created";
- $new_account_mail_body = __( 'Dear', 'wc-frontend-membership_registration-vendor-membership' ) . ' {first_name}' .
- ',<br/><br/>' .
- __( 'Your account has been created as {user_role}. Follow the bellow details to log into the system', 'wc-frontend-membership_registration-vendor-membership' ) .
- '<br/><br/>' .
- __( 'Site', 'wc-frontend-membership_registration-vendor-membership' ) . ': https://atomicedge.io' .
- '<br/>' .
- __( 'Login', 'wc-frontend-membership_registration-vendor-membership' ) . ': {username}' .
- '<br/>' .
- __( 'Password', 'wc-frontend-membership_registration-vendor-membership' ) . ': {password}' .
- '<br /><br/>Thank You';
-
- $wcfmgs_new_account_mail_subject = get_option( 'wcfmgs_new_account_mail_subject' );
- if( $wcfmgs_new_account_mail_subject ) $new_account_mail_subject = $wcfmgs_new_account_mail_subject;
- $wcfmgs_new_account_mail_body = get_option( 'wcfmgs_new_account_mail_body' );
- if( $wcfmgs_new_account_mail_body ) $new_account_mail_body = $wcfmgs_new_account_mail_body;
-
- $subject = str_replace( '{site_name}', get_bloginfo( 'name' ), $new_account_mail_subject );
- $subject = apply_filters( 'wcfm_email_subject_wrapper', $subject );
- $message = str_replace( 'https://atomicedge.io', get_bloginfo( 'url' ), $new_account_mail_body );
- $message = str_replace( '{first_name}', $wcfm_membership_registration_form_data['first_name'], $message );
- $message = str_replace( '{username}', $wcfm_membership_registration_form_data['user_name'], $message );
- $message = str_replace( '{password}', $password, $message );
- $message = str_replace( '{user_role}', 'Shop Membership_registration', $message );
- $message = apply_filters( 'wcfm_email_content_wrapper', $message, __( 'New Account', 'wc-frontend-manager' ) );
-
- wp_mail( $mail_to, $subject, $message );
- }*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- // Update First Name as Billing & Shipping First Name
+
if (isset($wcfm_membership_registration_form_data['first_name'])) {
update_user_meta($member_id, 'billing_first_name', $wcfm_membership_registration_form_data['first_name']);
update_user_meta($member_id, 'shipping_first_name', $wcfm_membership_registration_form_data['first_name']);
}
- // Update Last Name as Billing & Shipping Last Name
+
if (isset($wcfm_membership_registration_form_data['last_name'])) {
update_user_meta($member_id, 'billing_last_name', $wcfm_membership_registration_form_data['last_name']);
update_user_meta($member_id, 'shipping_last_name', $wcfm_membership_registration_form_data['last_name']);
}
- // Update Store Address as Billing & Shipping Address
+
$wcfmvm_registration_static_fields = wcfm_get_option('wcfmvm_registration_static_fields', array());
if (!empty($wcfmvm_registration_static_fields) && isset($wcfm_membership_registration_form_data['wcfmvm_static_infos']) && !empty($wcfm_membership_registration_form_data['wcfmvm_static_infos'])) {
foreach ($wcfmvm_registration_static_fields as $wcfmvm_registration_static_field => $wcfmvm_registration_static_field_val) {
@@ -389,26 +398,26 @@
}
}
- // Update Store name
+
if (!wcfm_is_vendor() && isset($wcfm_membership_registration_form_data['store_name']) && !empty($wcfm_membership_registration_form_data['store_name'])) {
update_user_meta($member_id, 'store_name', $wcfm_membership_registration_form_data['store_name']);
update_user_meta($member_id, 'wcfmmp_store_name', $wcfm_membership_registration_form_data['store_name']);
}
- // Update User Membership
+
if (WC()->session && WC()->session->get('wcfm_membership')) {
$wcfm_membership = WC()->session->get('wcfm_membership');
update_user_meta($member_id, 'temp_wcfm_membership', $wcfm_membership);
- } elseif ($wcfm_membership = get_wcfm_free_membership()) {
+ } elseif ($wcfm_membership = get_wcfm_selectable_free_membership()) {
update_user_meta($member_id, 'temp_wcfm_membership', $wcfm_membership);
}
- // Update Static Infos - 1.0.6
+
if (isset($wcfm_membership_registration_form_data['wcfmvm_static_infos'])) {
update_user_meta($member_id, 'wcfmvm_static_infos', $wcfm_membership_registration_form_data['wcfmvm_static_infos']);
}
- // Direct File Upload - 2.3.0
+
if (!empty($files_data)) {
if (!isset($wcfm_membership_registration_form_data['wcfmvm_custom_infos'])) $wcfm_membership_registration_form_data['wcfmvm_custom_infos'] = $files_data;
else {
@@ -416,12 +425,12 @@
}
}
- // Update Additional Infos - 1.0.5
+
if (!wcfm_is_vendor() && isset($wcfm_membership_registration_form_data['wcfmvm_custom_infos'])) {
update_user_meta($member_id, 'wcfmvm_custom_infos', $wcfm_membership_registration_form_data['wcfmvm_custom_infos']);
- // Toolset User Fields Compatibility added
- $wcfmvm_registration_custom_fields = wcfm_get_option('wcfmvm_registration_custom_fields', array());
+
+ $wcfmvm_registration_custom_fields = wcfmvm_get_registration_custom_fields(get_user_meta($member_id, 'temp_wcfm_membership', true), $member_id);
$wcfmvm_custom_infos = (array) $wcfm_membership_registration_form_data['wcfmvm_custom_infos'];
if (!empty($wcfmvm_registration_custom_fields)) {
@@ -448,7 +457,7 @@
}
}
- // Email Verification Update - 1.3.2
+
if (apply_filters('wcfm_is_allow_email_verification', true) && $email_verification) {
if ($email_verified) {
update_user_meta($member_id, '_wcfm_email_verified', true);
@@ -461,7 +470,7 @@
}
update_user_meta($member_id, 'wcemailverified', 'true');
- // SMS Verification Update - 2.3.0
+
if (apply_filters('wcfm_is_allow_sms_verification', true) && function_exists('wcfm_is_store_page') && $sms_verification) {
if ($sms_verified) {
update_user_meta($member_id, '_wcfm_sms_verified', true);
@@ -473,7 +482,7 @@
}
}
- // Free Membership Registration - 1.2.0
+
if (empty($wcfm_memberships_list) || (WC()->session && WC()->session->get('wcfm_membership_free_registration'))) {
$member_user = new WP_User(absint($member_id));
$shop_name = $wcfm_membership_registration_form_data['store_name'];
@@ -493,7 +502,7 @@
}
} elseif (WC()->session && WC()->session->get('wcfm_membership')) {
$wcfm_membership = absint(WC()->session->get('wcfm_membership'));
- // Set WC Cart for WC Checout Pay Mode - 1.3.0
+
$subscription = (array) get_post_meta($wcfm_membership, 'subscription', true);
$subscription_pay_mode = isset($subscription['subscription_pay_mode']) ? $subscription['subscription_pay_mode'] : 'by_wcfm';
$subscription_product = isset($subscription['subscription_product']) ? $subscription['subscription_product'] : '';
--- a/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-settings.php
+++ b/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-settings.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin controllers
- *
- * Plugin Membership Settings Controller
- *
- * @author WC Lovers
- * @package wcfmvm/controllers
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Memberships_Settings_Controller {
@@ -21,7 +21,7 @@
global $WCFM, $WCFMvm, $_POST, $wpdb, $wcfm_membership_settings_form_data;
$wcfm_membership_settings_form_data = array();
- parse_str($_POST['wcfm_membership_settings_form'], $wcfm_membership_settings_form_data);
+ parse_str( wp_unslash( $_POST['wcfm_membership_settings_form'] ), $wcfm_membership_settings_form_data );
$wcfm_membership_settings_form_data = wc_clean( $wcfm_membership_settings_form_data );
@@ -37,11 +37,11 @@
update_option( 'wcfm_membership_options', $wcfm_membership_settings_form_data );
if( isset( $_POST['free_thankyou_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_free_thankyou_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['free_thankyou_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_free_thankyou_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['free_thankyou_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $_POST['subscription_thankyou_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_subscription_thankyou_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['subscription_thankyou_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_subscription_thankyou_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['subscription_thankyou_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['non_membership_welcome_email_subject'] ) ) {
@@ -49,7 +49,7 @@
}
if( isset( $_POST['non_membership_welcome_email_content'] ) ) {
- wcfm_update_option( 'wcfm_non_membership_welcome_email_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['non_membership_welcome_email_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_non_membership_welcome_email_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['non_membership_welcome_email_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['subscription_welcome_email_subject'] ) ) {
@@ -57,7 +57,7 @@
}
if( isset( $_POST['subscription_welcome_email_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_subscription_welcome_email_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['subscription_welcome_email_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_subscription_welcome_email_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['subscription_welcome_email_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['registration_admin_notication_subject'] ) ) {
@@ -65,7 +65,7 @@
}
if( isset( $_POST['registration_admin_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_registration_admin_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['registration_admin_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_registration_admin_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['registration_admin_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['subscription_admin_notication_subject'] ) ) {
@@ -73,7 +73,7 @@
}
if( isset( $_POST['subscription_admin_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_subscription_admin_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['subscription_admin_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_subscription_admin_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['subscription_admin_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['onapproval_admin_notication_subject'] ) ) {
@@ -81,7 +81,7 @@
}
if( isset( $_POST['onapproval_admin_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_onapproval_admin_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['onapproval_admin_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_onapproval_admin_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['onapproval_admin_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['switch_admin_notication_subject'] ) ) {
@@ -89,7 +89,7 @@
}
if( isset( $_POST['switch_admin_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_switch_admin_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['switch_admin_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_switch_admin_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['switch_admin_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['switch_notication_subject'] ) ) {
@@ -97,7 +97,7 @@
}
if( isset( $_POST['switch_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_switch_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['switch_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_switch_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['switch_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['next_payment_notication_subject'] ) ) {
@@ -105,7 +105,7 @@
}
if( isset( $_POST['next_payment_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_next_payment_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['next_payment_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_next_payment_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['next_payment_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['reminder_notication_subject'] ) ) {
@@ -113,7 +113,7 @@
}
if( isset( $_POST['reminder_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_reminder_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['reminder_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_reminder_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['reminder_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['reject_notication_subject'] ) ) {
@@ -121,7 +121,7 @@
}
if( isset( $_POST['reject_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_reject_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['reject_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_reject_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['reject_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['cancel_notication_subject'] ) ) {
@@ -129,7 +129,7 @@
}
if( isset( $_POST['cancel_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_cancel_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['cancel_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_cancel_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['cancel_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['expire_notication_subject'] ) ) {
@@ -137,7 +137,7 @@
}
if( isset( $_POST['expire_notication_content'] ) ) {
- wcfm_update_option( 'wcfm_membership_expire_notication_content', wp_filter_post_kses( stripslashes( html_entity_decode( $_POST['expire_notication_content'], ENT_QUOTES, 'UTF-8' ) ) ) );
+ wcfm_update_option( 'wcfm_membership_expire_notication_content', wp_kses_post( html_entity_decode( wp_unslash( $_POST['expire_notication_content'] ), ENT_QUOTES, 'UTF-8' ) ) );
}
if( isset( $wcfm_membership_settings_form_data['wcfmvm_registration_static_fields'] ) ) {
@@ -150,7 +150,7 @@
wcfm_update_option( 'wcfmvm_registration_custom_fields', $wcfm_membership_settings_form_data['wcfmvm_registration_custom_fields'] );
}
- // Init WCFM membership Display Custom CSS file
+
$wcfmvm_style_custom = $WCFMvm->wcfmvm_create_membership_css();
do_action( 'wcfm_membership_settings_update', $wcfm_membership_settings_form_data );
--- a/wc-multivendor-membership/controllers/wcfmvm-controller-memberships.php
+++ b/wc-multivendor-membership/controllers/wcfmvm-controller-memberships.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin controllers
- *
- * Plugin WCFMvm Memberships Dashboard Controller
- *
- * @author WC Lovers
- * @package wcfmvm/controllers
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Memberships_Controller {
@@ -37,7 +37,7 @@
'post_type' => 'wcfm_memberships',
'post_mime_type' => '',
'post_parent' => '',
- //'author' => get_current_user_id(),
+
'post_status' => array('draft', 'pending', 'publish'),
'suppress_filters' => true
);
@@ -47,21 +47,21 @@
$wcfm_memberships_array = get_posts( $args );
- // Get Group Count
+
$group_count = 0;
$filtered_group_count = 0;
$wcfm_memberships_count = wp_count_posts('wcfm_vendor_memberships');
foreach($wcfm_memberships_count as $wcfm_membership_count ) {
$group_count += $wcfm_membership_count;
}
- // Get Filtered Post Count
+
$args['posts_per_page'] = -1;
$args['offset'] = 0;
$wcfm_filterd_memberships_array = get_posts( $args );
$filtered_group_count = count($wcfm_filterd_memberships_array);
$is_marketplace = wcfm_is_marketplace();
- // Generate Memberships JSON
+
$wcfm_memberships_json = '';
$wcfm_memberships_json = '{
"draw": ' . wc_clean($_POST['draw']) . ',
@@ -72,10 +72,10 @@
$index = 0;
$wcfm_memberships_json_arr = array();
foreach($wcfm_memberships_array as $wcfm_memberships_single) {
- // Group
+
$wcfm_memberships_json_arr[$index][] = '<a href="' . esc_url(get_wcfm_memberships_manage_url($wcfm_memberships_single->ID)) . '" class="wcfm_dashboard_item_title">' . $wcfm_memberships_single->post_title . '</a>';
- // Details
+
$membership_details = __( 'Plan type: ', 'wc-multivendor-membership' );
$subscription = (array) get_post_meta( $wcfm_memberships_single->ID, 'subscription', true );
$membership_details .= isset( $subscription['is_free'] ) ? 'FREE' : '';
@@ -92,7 +92,7 @@
$wcfm_memberships_json_arr[$index][] = $membership_details;
- // Pay Mode
+
$subscription_pay_mode = isset( $subscription['subscription_pay_mode'] ) ? $subscription['subscription_pay_mode'] : 'by_wcfm';
$subscription_product = isset( $subscription['subscription_product'] ) ? $subscription['subscription_product'] : '';
$pay_mods = array( 'by_wc' => __( 'WC Checkout', 'wc-multivendor-membership' ), 'by_wcfm' => __( 'Integrate Payment Options', 'wc-multivendor-membership' ) );
@@ -102,7 +102,7 @@
}
$wcfm_memberships_json_arr[$index][] = $pay_mode;
- // Associated Group
+
if( WCFM_Dependencies::wcfmgs_plugin_active_check() ) {
$associated_group = get_post_meta( $wcfm_memberships_single->ID, 'associated_group', true );
if( $associated_group ) {
@@ -114,7 +114,7 @@
$wcfm_memberships_json_arr[$index][] = '<span class="manager_count">–</span>';
}
- // User Count
+
$membership_users = get_post_meta( $wcfm_memberships_single->ID, 'membership_users', true );
if( $is_marketplace ) {
if( $membership_users && is_array( $membership_users ) ) {
@@ -126,7 +126,7 @@
$wcfm_memberships_json_arr[$index][] = '<span class="vendor_count">–</span>';
}
- // Action
+
$actions = '<a class="wcfm-action-icon" href="' . esc_url(get_wcfm_memberships_manage_url($wcfm_memberships_single->ID)) . '"><span class="wcfmfa fa-edit text_tip" data-tip="' . esc_attr__( 'Edit', 'wc-frontend-manager' ) . '"></span></a>';
if( $membership_users && is_array( $membership_users ) && ( count( $membership_users ) > 0 ) && apply_filters( 'wcfm_is_allow_block_membership_delete', false ) ) {
$actions .= '<a class="wcfm_membership_restrict_delete wcfm-action-icon" href="#"><span class="wcfmfa fa-trash-alt text_tip" data-tip="' . esc_attr__( 'Delete', 'wc-frontend-manager' ) . '"></span></a>';
--- a/wc-multivendor-membership/core/class-wcfmvm-ajax.php
+++ b/wc-multivendor-membership/core/class-wcfmvm-ajax.php
@@ -1,18 +1,18 @@
<?php
-/**
- * WCFM Membership plugin core
- *
- * Plugin Ajax Controler
- *
- * @author WC Lovers
- * @package wcfmvm/core
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Ajax {
- /**
- * @var string $controllers_path
- */
+
+
+
public $controllers_path;
public function __construct() {
@@ -23,49 +23,49 @@
add_action( 'after_wcfm_ajax_controller', array( &$this, 'wcfmvm_ajax_controller' ) );
add_action( 'wp_ajax_nopriv_wcfm_ajax_controller', array( &$this, 'wcfmvm_ajax_controller' ) );
- // Choose Membship Plan
+
add_action( 'wp_ajax_wcfm_choose_membership', array( &$this, 'wcfm_choose_membership' ) );
add_action( 'wp_ajax_nopriv_wcfm_choose_membership', array( &$this, 'wcfm_choose_membership' ) );
- // Generate Vendor Approval Response Html
+
add_action( 'wp_ajax_wcfmvm_vendor_approval_html', array( &$this, 'wcfmvm_vendor_approval_html' ) );
- // Update Vendor Approval Response
+
add_action( 'wp_ajax_wcfmvm_vendor_approval_response_update', array( &$this, 'wcfmvm_vendor_approval_response_update' ) );
- // Vendor membership cancel
+
add_action( 'wp_ajax_wcfmvm_membership_cancel', array( &$this, 'wcfmvm_membership_cancel' ) );
- // Vendor membership change
+
add_action( 'wp_ajax_wcfmvm_membership_change', array( &$this, 'wcfmvm_membership_change' ) );
- // Membership Delete
+
add_action( 'wp_ajax_delete_wcfm_membership', array( &$this, 'delete_wcfm_membership' ) );
- // Membership Schedule Change Html
+
add_action('wp_ajax_wcfmvm_change_next_renewal_html', array( &$this, 'wcfmvm_change_next_renewal_html' ) );
- // Membership Schedule Change Update
+
add_action( 'wp_ajax_wcfmvm_change_next_renewal', array( &$this, 'wcfmvm_change_next_renewal_update' ) );
- // Email Verification Code
+
add_action( 'wp_ajax_wcfmvm_email_verification_code', array( &$this, 'wcfmvm_email_verification_code' ) );
add_action( 'wp_ajax_nopriv_wcfmvm_email_verification_code', array( &$this, 'wcfmvm_email_verification_code' ) );
- // SMS Verification Code
+
add_action( 'wp_ajax_wcfmvm_sms_verification_code', array( &$this, 'wcfmvm_sms_verification_code' ) );
add_action( 'wp_ajax_nopriv_wcfmvm_sms_verification_code', array( &$this, 'wcfmvm_sms_verification_code' ) );
- // Store Slug Verification
+
add_action( 'wp_ajax_wcfmvm_store_slug_verification', array( &$this, 'wcfmvm_store_slug_verification' ) );
add_action( 'wp_ajax_nopriv_wcfmvm_store_slug_verification', array( &$this, 'wcfmvm_store_slug_verification' ) );
add_action( 'wp_ajax_wcfm-memberships-payment-paypal', array( &$this, 'wcfm_memberships_payment_paypal' ) );
}
- /**
- * WCFM Membership Ajax Controllers
- */
+
+
+
public function wcfmvm_ajax_controller() {
global $WCFM, $WCFMvm;
@@ -81,7 +81,7 @@
switch( $controller ) {
case 'wcfm-memberships':
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -91,7 +91,7 @@
break;
case 'wcfm-memberships-manage':
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -111,7 +111,7 @@
break;
case 'wcfm-memberships-settings':
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -123,9 +123,9 @@
}
}
- /**
- * WCFM Choose Membership Plan
- */
+
+
+
function wcfm_choose_membership() {
global $WCFM, $WCFMvm, $_SESSION;
@@ -135,7 +135,7 @@
}
if ( ! check_ajax_referer( 'wcfm_ajax_nonce', 'wcfm_ajax_nonce', false ) ) {
- if( $method != 'by_url' ) { // Have to look for alternate solution, static url not able to generate nonce url
+ if( $method != 'by_url' ) {
wp_send_json_error( esc_html__( 'Invalid nonce! Refresh your page and try again.', 'wc-frontend-manager' ) );
wp_die();
}
@@ -143,8 +143,16 @@
if( isset( $_REQUEST['membership'] ) && !empty( $_REQUEST['membership'] ) ) {
$membership = absint($_REQUEST['membership']);
+
+ if( !wcfm_is_selectable_membership( $membership ) ) {
+ if( $method == 'by_url' ) {
+ wp_safe_redirect( get_wcfm_membership_url() );
+ die;
+ }
+ wp_send_json_error( esc_html__( 'Invalid membership plan selected.', 'wc-multivendor-membership' ) );
+ }
- // Session store
+
if( WC()->session ) {
do_action( 'woocommerce_set_cart_cookies', true );
WC()->session->set( 'wcfm_membership', $membership );
@@ -209,9 +217,9 @@
die;
}
- /**
- * Generate Vendor Approval HTMl
- */
+
+
+
function wcfmvm_vendor_approval_html() {
global $WCFM, $WCFMvm;
@@ -220,7 +228,7 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -253,7 +261,7 @@
$wcfmvm_registration_static_fields = wcfm_get_option( 'wcfmvm_registration_static_fields', array() );
$wcfmvm_static_infos = (array) get_user_meta( $member_id, 'wcfmvm_static_infos', true );
- $wcfmvm_registration_custom_fields = wcfm_get_option( 'wcfmvm_registration_custom_fields', array() );
+ $wcfmvm_registration_custom_fields = wcfmvm_get_registration_custom_fields( get_user_meta( $member_id, 'temp_wcfm_membership', true ), $member_id );
$wcfmvm_custom_infos = (array) get_user_meta( $member_id, 'wcfmvm_custom_infos', true );
?>
@@ -292,7 +300,7 @@
</tr>
<?php } ?>
<?php
- // Registration Static Field Support - 1.0.6
+
if( !empty( $wcfmvm_registration_static_fields ) ) {
foreach( $wcfmvm_registration_static_fields as $wcfmvm_registration_static_field => $wcfmvm_registration_static_field_val ) {
$field_value = array();
@@ -338,7 +346,7 @@
}
- // Registration Custom Field Support - 1.0.5
+
if( !empty( $wcfmvm_registration_custom_fields ) ) {
foreach( $wcfmvm_registration_custom_fields as $wcfmvm_registration_custom_field ) {
if( !isset( $wcfmvm_registration_custom_field['enable'] ) ) continue;
@@ -410,13 +418,13 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
$wcfm_vendor_approval_response_form_data = array();
- parse_str($_POST['wcfm_vendor_approval_response_form'], $wcfm_vendor_approval_response_form_data);
+ parse_str( wp_unslash( $_POST['wcfm_vendor_approval_response_form'] ), $wcfm_vendor_approval_response_form_data );
$wcfm_vendor_approval_response_form_data = wc_clean( $wcfm_vendor_approval_response_form_data );
@@ -461,13 +469,12 @@
if( !defined( 'DOING_WCFM_EMAIL' ) )
define( 'DOING_WCFM_EMAIL', true );
- // Switch language context…
+
if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
do_action('wpml_switch_language_for_email', $member_user->user_email);
}
$rejection_reason = wcfm_stripe_newline( $wcfm_vendor_approval_response_form_data['wcfm_vendor_rejection_reason'] );
- $rejection_reason = esc_sql( $rejection_reason );
$reject_notication_subject = wcfm_get_option( 'wcfm_membership_reject_notication_subject', '{site_name}: Vendor Application Rejected' );
$reject_notication_content = wcfm_get_option( 'wcfm_membership_reject_notication_content', '' );
@@ -483,13 +490,14 @@
$subject = str_replace( '{site_name}', get_bloginfo( 'name' ), $reject_notication_subject );
$subject = apply_filters( 'wcfm_email_subject_wrapper', $subject );
- $message = str_replace( '{first_name}', $member_user->first_name, $reject_notication_content );
+ $message = str_replace( '{first_name}', esc_html( $member_user->first_name ), $reject_notication_content );
+ $message = str_replace( '{site_name}', get_bloginfo( 'name' ), $message );
$message = str_replace( '{rejection_reason}', $rejection_reason, $message );
$message = apply_filters( 'wcfm_email_content_wrapper', $message, __( 'Vendor Application Rejected', 'wc-multivendor-membership' ) );
wp_mail( $member_user->user_email, $subject, $message );
- // switch language back
+
if( apply_filters( 'wcfm_allow_wpml_email_translation', true ) ) {
do_action('wpml_restore_language_from_email');
}
@@ -509,15 +517,15 @@
}
}
- // Vendor Approval message mark read
+
$author_id = apply_filters( 'wcfm_message_author', get_current_user_id() );
$todate = date('Y-m-d H:i:s');
- /*$wcfm_read_message = "INSERT into {$wpdb->prefix}wcfm_messages_modifier
- (`message`, `is_read`, `read_by`, `read_on`)
- VALUES
- ({$message_id}, 1, {$author_id}, '{$todate}')";
- $wpdb->query($wcfm_read_message);*/
+
+
+
+
+
$wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->prefix}wcfm_messages WHERE ID =%d", $message_id ) );
@@ -529,9 +537,9 @@
die;
}
- /**
- * Vednor membership cancel
- */
+
+
+
function wcfmvm_membership_cancel() {
global $WCFM, $WCFMvm, $_POST, $wpdb;
@@ -569,9 +577,9 @@
die;
}
- /**
- * Vednor membership change byAdmin
- */
+
+
+
function wcfmvm_membership_change() {
global $WCFM, $WCFMvm, $_POST, $wpdb;
@@ -580,23 +588,26 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'wcfm_vendor' ) && !current_user_can( 'seller' ) && !current_user_can( 'vendor' ) && !current_user_can( 'shop_staff' ) ) {
+
+
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
if( isset( $_POST['memberid'] ) && isset($_POST['membershipid']) ) {
$member_id = absint( $_POST['memberid'] );
- $user_id = apply_filters('wcfm_current_vendor_id', get_current_user_id());
- if ( function_exists( 'wcfm_user_can_perform_request' ) && !wcfm_user_can_perform_request( $member_id, 'wcfm_membership' ) ) {
- echo '{"status": false, "message": "' . esc_html( __( 'You do not have permission to do this.', 'wc-multivendor-membership' ) ) . '"}';
- die;
- } elseif ( !function_exists( 'wcfm_user_can_perform_request' ) && !current_user_can( 'manage_woocommerce' ) && ( $user_id != $member_id ) ) {
+ if ( !$member_id || !wcfmvm_current_user_can_manage_memberships( $member_id ) ) {
echo '{"status": false, "message": "' . esc_html( __( 'You do not have permission to do this.', 'wc-multivendor-membership' ) ) . '"}';
die;
}
$wcfm_membership_id = absint( $_POST['membershipid'] );
+ $wcfm_membership = get_post( $wcfm_membership_id );
+ if ( !$wcfm_membership || ( 'wcfm_memberships' !== $wcfm_membership->post_type ) || ( 'publish' !== $wcfm_membership->post_status ) ) {
+ echo '{"status": false, "message": "' . esc_html( __( 'Vendor membership can not be changed right now, please try after sometime.', 'wc-multivendor-membership' ) ) . '"}';
+ die;
+ }
$member_user = new WP_User( $member_id );
$shop_name = get_user_meta( $member_id, 'store_name', true );
$old_membership_id = get_user_meta( $member_id, 'wcfm_membership', true );
@@ -615,9 +626,9 @@
die;
}
- /**
- * Handle membership Delete
- */
+
+
+
public function delete_wcfm_membership() {
global $WCFM, $WCFMvm;
@@ -626,7 +637,7 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -642,9 +653,9 @@
}
}
- /**
- * Membership Schedule Change HTML
- */
+
+
+
function wcfmvm_change_next_renewal_html() {
global $WCFM, $WCFMvm;
@@ -653,7 +664,7 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -678,9 +689,9 @@
die;
}
- /**
- * Membership Next Schedule Update
- */
+
+
+
function wcfmvm_change_next_renewal_update() {
global $WCFM, $WCFMvm;
@@ -689,7 +700,7 @@
wp_die();
}
- if ( !current_user_can( 'manage_woocommerce' ) && !current_user_can( 'shop_staff' ) ) {
+ if ( !wcfmvm_current_user_can_manage_memberships() ) {
wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
wp_die();
}
@@ -697,6 +708,11 @@
$next_renewal = wc_clean($_POST['next_renewal']);
$member_id = absint($_POST['member']);
+ if ( !$member_id || !wcfmvm_current_user_can_manage_memberships( $member_id ) ) {
+ wp_send_json_error( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) );
+ wp_die();
+ }
+
if( $next_renewal ) {
$next_renewal = strtotime( wcfm_standard_date( $next_renewal ) );
update_user_meta( $member_id, 'wcfm_membership_next_schedule', $next_renewal );
@@ -710,9 +726,9 @@
die;
}
- /**
- * WCfM Registration email verification code send
- */
+
+
+
function wcfmvm_email_verification_code() {
global $WCFM, $WCFMvm, $_SESSION;
@@ -734,30 +750,30 @@
} else {
$verification_code = rand( 100000, 999999 );
}
- // Session store
+
if( WC()->session ) {
do_action( 'woocommerce_set_cart_cookies', true );
WC()->session->set( 'wcfm_membership_email_verification_code', $verification_code );
WC()->session->set( 'wcfm_membership_email_verification_for', $user_email );
}
- // Sending verification code in email
+
if( !defined( 'DOING_WCFM_EMAIL' ) )
define( 'DOING_WCFM_EMAIL', true );
- /*$verification_mail_subject = "{site_name}: " . __( "Email Verification Code", "wc-frontend-manager" ) . " - " . $verification_code;
- $verification_mail_body = __( 'Hi', 'wc-multivendor-membership' ) .
- ',<br/><br/>' .
- apply_filters( 'wcfm_email_verification_mail_content', sprintf( __( 'Here is your email verification code - <b>%s</b>', 'wc-multivendor-membership' ), '{verification_code}' ) ) .
- '<br /><br/>' . __( 'Thank You', 'wc-multivendor-membership' );
-
- $subject = str_replace( '{site_name}', get_bloginfo( 'name' ), $verification_mail_subject );
- $subject = apply_filters( 'wcfm_email_subject_wrapper', $subject );
- $subject = str_replace( '{verification_code}', $verification_code, $subject );
- $message = str_replace( '{verification_code}', $verification_code, $verification_mail_body );
- $message = apply_filters( 'wcfm_email_content_wrapper', $message, __( 'Email Verification', 'wc-multivendor-membership' ) );
-
- wp_mail( $user_email, $subject, $message );*/
+
+
+
+
+
+
+
+
+
+
+
+
+
$wcfm_email = WC()->mailer()->emails['WCFMvm_Email_Email_verification'];
@@ -772,9 +788,9 @@
die;
}
- /**
- * WCfM Registration SMS - OTP verification code send
- */
+
+
+
function wcfmvm_sms_verification_code() {
global $WCFM, $WCFMvm, $WCFMmp, $_SESSION;
@@ -801,14 +817,14 @@
} else {
$verification_code = rand( 1000, 9999 );
}
- // Session store
+
if( WC()->session ) {
do_action( 'woocommerce_set_cart_cookies', true );
WC()->session->set( 'wcfm_membership_sms_verification_code', $verification_code );
WC()->session->set( 'wcfm_membership_sms_verification_for', $user_phone );
}
- //$sms_messages = $verification_code . ' - ' . __( "verification code (OPT) for registration at ", "wc-frontend-manager" ) . get_bloginfo( 'name' );
+
$sms_messages = __( "Your verification code is", "wc-multivendor-membership" ) . ' ' . $verification_code;
$sms_messages = strip_tags( $sms_messages );
@@ -864,7 +880,7 @@
$recipient = $user_phone;
if( $recipient ) {
wcfm_log( "OPT:: " . $recipient . ": " . $sms_messages );
- // removed @2.10.2, core plugin no more available
+
}
}
@@ -891,9 +907,9 @@
die;
}
- /**
- * Store Name Validation
- */
+
+
+
function wcfmvm_store_slug_verification() {
global $WCFM, $WCFMvm, $_SESSION;
@@ -935,11 +951,11 @@
die;
}
- /**
- * Process Membership Paypal payment
- */
+
+
+
function wcfm_memberships_payment_paypal() {
- // proceed only after a valid nonce check
+
if (!check_ajax_referer('wcfm_ajax_nonce', 'wcfm_ajax_nonce', false)) {
wp_send_json_error(esc_html__('Invalid nonce! Refresh your page and try again.', 'wc-frontend-manager'));
wp_die();
@@ -992,7 +1008,7 @@
'business' => esc_attr($paypal_email),
'currency_code' => esc_attr($payment_currency),
'item_number' => esc_attr($membership_id),
- 'item_name' => substr(esc_attr($title . ' - ' . $description), 0, 20), // maxlength 20 characters
+ 'item_name' => substr(esc_attr($title . ' - ' . $description), 0, 20),
'no_shipping' => 1,
'notify_url' => esc_url(add_query_arg( 'wcfmvm_process_ipn', 'paypal_ipn', get_wcfm_membership_url() )),
'return' => esc_url(apply_filters( 'wcfm_registration_thankyou_url', add_query_arg( 'vmstep', 'thankyou', get_wcfm_membership_url() ) )),
@@ -1000,10 +1016,10 @@
'custom' => esc_attr($member_id),
];
- // PayPal accepts at most two decimals (none for zero decimal currencies)
- // and the IPN handler compares what PayPal reports back against these
- // same wc_format_decimal() rounded values - an unrounded tax result like
- // 23.988 would be rejected at PayPal or fail the IPN amount check.
+
+
+
+
if ($subscription_type == 'one_time') {
$body['cmd'] = '_xclick';
$body['amount'] = wc_format_decimal( wcfmvm_membership_tax_price($one_time_amt), wc_get_price_decimals() );
--- a/wc-multivendor-membership/core/class-wcfmvm-capability.php
+++ b/wc-multivendor-membership/core/class-wcfmvm-capability.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin core
- *
- * Plugin Capability Controller
- *
- * @author WC Lovers
- * @package wcfmvm/core
- * @version 1.0.1
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Capability {
@@ -21,7 +21,7 @@
add_filter( 'wcfm_is_allow_membership', array( &$this, 'wcfmcap_is_allow_membership' ), 500 );
}
- // WCFM wcfmcap Membership
+
function wcfmcap_is_allow_membership( $allow ) {
if( wcfm_is_vendor() ) return false;
$membership = ( isset( $this->wcfm_capability_options['membership'] ) ) ? $this->wcfm_capability_options['membership'] : 'no';
--- a/wc-multivendor-membership/core/class-wcfmvm-emails.php
+++ b/wc-multivendor-membership/core/class-wcfmvm-emails.php
@@ -1,13 +1,13 @@
<?php
-/**
- * WCFM plugin core
- *
- * WCfM Emails
- *
- * @author WC Lovers
- * @package wcfm/core
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Emails {
@@ -48,6 +48,6 @@
if( file_exists( $WCFMvm->plugin_path . 'includes/emails/class-wcfmvm-email-' . esc_attr($wcfm_email) . '.php' ) ) {
require_once ( $WCFMvm->plugin_path . 'includes/emails/class-wcfmvm-email-' . esc_attr($wcfm_email) . '.php' );
}
- } // End If Statement
+ }
}
}
No newline at end of file
--- a/wc-multivendor-membership/core/class-wcfmvm-frontend.php
+++ b/wc-multivendor-membership/core/class-wcfmvm-frontend.php
@@ -1,51 +1,51 @@
<?php
-/**
- * WCFM Vendor Membership plugin core
- *
- * Plugin Frontend Controler
- *
- * @author WC Lovers
- * @package wcfmvm/core
- * @version 1.0.0
- */
+
+
+
+
+
+
+
+
+
class WCFMvm_Frontend {
public function __construct() {
global $WCFM, $WCFMvm;
- // WCFM Membership Page Template
+
add_action( 'page_template', array( &$this, 'wcfm_membership_template' ) );
if( apply_filters( 'wcfm_is_allow_manage_groups', true ) ) {
- // WCFM Membership End Points
+
add_filter( 'wcfm_query_vars', array( &$this, 'wcfmvm_vendor_membership_wcfm_query_vars' ), 90 );
add_filter( 'wcfm_endpoint_title', array( &$this, 'wcfmvm_vendor_membership_endpoint_title' ), 90, 2 );
add_action( 'init', array( &$this, 'wcfmvm_vendor_membership_init' ), 90 );
- // WCFM Membership Page
+
add_filter( 'wcfm_settings_fields_pages', array( $this, 'wcfmvm_settings_fields_pages' ) );
- // WCFM Membership Endpoint Edit
+
add_filter( 'wcfm_endpoints_slug', array( $this, 'wcfmvm_vendor_membership_endpoints_slug' ) );
- // WCFM Menu Filter
+
add_filter( 'wcfm_menus', array( &$this, 'wcfmvm_vendor_membership_menus' ), 300 );
add_filter( 'wcfm_menu_dependancy_map', array( &$this, 'wcfmvm_vendor_membership_menu_dependancy_map' ) );
}
- // Vendor Details Page
+
if( !wcfm_is_vendor() && apply_filters( 'wcfm_is_allow_manage_groups', true ) ) {
- //add_action( 'after_wcfm_vendors_manage_form', array( &$this, 'wcfmvm_vendor_manage_profile_additional_info' ), 12 );
+
add_action( 'after_wcfm_vendors_manage_membership_details', array( &$this, 'wcfmvm_vendor_manage_membership_additional_info' ), 12 );
add_action( 'wcfm_vendor_manage_membrship_details', array( &$this, 'wcfmvm_vendor_manage_membrship_details' ), 12 );
}
- // Membership Details in Profile
+
if( wcfm_is_vendor() && apply_filters( 'wcfm_is_allow_vendor_membership', true ) ) {
if( apply_filters( 'wcfm_is_pref_membership', true ) ) {
add_action( 'wcfm_dashboard_after_username', array( &$this, 'wcfmvm_vendor_dashboard_username' ), 12 );
- //add_action( 'end_wcfm_vendor_settings', array( &$this, 'wcfmvm_vendor_membership_user_setting_block' ), 12 );
+
add_action( 'wcfm_vendor_setting_header_after', array( &$this, 'wcfmvm_vendor_membership_user_setting_header' ), 12 );
add_action( 'end_wcfm_user_profile', array( &$this, 'wcfmvm_vendor_membership_user_profile' ), 12 );
if( apply_filters( 'wcfm_is_allow_membership_manage_under_setting', false ) ) {
@@ -54,44 +54,44 @@
}
}
- // Show Membership Plan change option when product limit reached
+
if( wcfm_is_vendor() ) {
add_action( 'wcfm_product_limit_pay_for_product_after', array( &$this, 'wcfmvm_after_pay_per_product_option' ) );
add_action( 'wcfm_product_limit_reached', array( &$this, 'wcfmvm_change_membership_option' ), 20 );
}
- // Membership direct message type
+
add_filter( 'wcfm_message_types', array( &$this, 'wcfm_membership_message_types' ), 50 );
- // WC Checkout for WCfM Membership products thank you redirect
+
add_action( 'woocommerce_thankyou', array( &$this, 'wcfmvm_thankyou_redirect_on_membership_purchase' ) );
- // Custom Plan Page Redirect support added
+
add_filter( 'wcfm_change_membership_url', array( &$this, 'wcfm_membership_custom_plan_url' ), 50 );
- // Custom Thank You Page Redirect support added
+
add_filter( 'wcfm_registration_thankyou_url', array( &$this, 'wcfm_membership_custom_thankyou_url' ), 50 );
- // Membership Subscription First Step
+
add_filter( 'wcfmvm_is_allow_registration_first', array( &$this, 'wcfmvm_registration_first_step' ), 50 );
- // Membership enqueue scripts
+
add_action('wp_enqueue_scripts', array(&$this, 'wcfmvm_scripts'));
- // Membership enqueue styles
+
add_action('wp_enqueue_scripts', array(&$this, 'wcfmvm_styles'));
- // Membership email translation support based on membership page language (wpml)
+