// WC – limit one course at a time (id 50697 / Fundamentals Public Safety) add_filter( ‘woocommerce_add_to_cart_validation’, ‘wc_limit_one_50697_per_order’, 10, 2 ); function wc_limit_one_50697_per_order( $passed_validation, $product_id ) { if ( 50697 !== $product_id ) { return $passed_validation; } if ( WC()->cart->get_cart_contents_count()…Continue reading
// add order suffix add_filter(‘woe_get_order_value_order_number’, ‘suffix_order_id_for_product_50697’, 10, 2 ); function suffix_order_id_for_product_50697( $order_id, $order ) { // Check if the order contains the specified product $product_id_to_check = 50697; $order_contains_product = false; foreach ( $order->get_items() as $item_id => $item ) { if…Continue reading
// add order suffix add_filter(‘woe_get_order_value_order_number’, ‘suffix_order_id_for_product_45639’, 10, 2 ); function suffix_order_id_for_product_45639( $order_id, $order ) { // Check if the order contains the specified product $product_id_to_check = 45639; $order_contains_product = false; foreach ( $order->get_items() as $item_id => $item ) { if…Continue reading
// WC – avoid other items to be added to cart when a specific product category (free courses) is already in cart add_filter( ‘woocommerce_add_to_cart_validation’, ‘check_and_limit_cart_free_items’, 10, 3 ); function check_and_limit_cart_free_items ( $passed, $product_id, $quantity ){ // HERE set your product…Continue reading
/** * Change Membership Level on Cancellation or Expiration * * Change the Level ID on line 30 to the level you want members to have assigned * to them after cancellation or expiration. * * title: Change Membership Level…Continue reading
/** * Filter the settings of email frequency sent when using the Extra Expiration Warning Emails Add On * https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/ * * Update the $settings array to your list of number of days => ”. * Read the Add On…Continue reading
add_action( ‘pmpro_after_change_membership_level’, ‘remove_old_roles_on_membership_upgrade’, 10, 2 ); function remove_old_roles_on_membership_upgrade( $level_id, $user_id ) { // Get the user’s current roles $user = new WP_User( $user_id ); $current_roles = $user->roles; // Define your membership level to role mapping $membership_roles = array( ‘1’ =>…Continue reading
add_action(‘user_register’, ‘capture_user_registration_details’, 10, 1); function capture_user_registration_details($user_id) { $user_info = get_userdata($user_id); // Capture and store registration details $details = [ ‘First name’ => $user_info->first_name, ‘Last name’ => $user_info->last_name, ‘Email’ => $user_info->user_email, ]; // Store details in a transient, expire after 1…Continue reading
function restrict_specific_characters($errors, $sanitized_user_login, $user_email) { // Regular expression for matching Japanese, Chinese, and Cyrillic characters // Japanese: U+3040–U+30FF (Hiragana and Katakana), U+4E00–U+9FBF (Common Kanji) // Chinese (Simplified + Traditional): U+4E00–U+9FFF // Russian (Cyrillic): U+0400–U+04FF // This is a simplified check…Continue reading
function change_expired_membership_to_level_one($level_id, $user_id, $cancel_level) { // Check if the bypass flag is set if (get_user_meta($user_id, ‘bypass_expiration’, true) == ‘yes’) { // Reset the flag update_user_meta($user_id, ‘bypass_expiration’, ‘no’); return; // Exit the function to avoid changing the membership level } if…Continue reading