function ld_course_button_auto_shortcode() { if (!is_singular(‘sfwd-courses’)) return ”; // Only show on course pages $course_id = get_the_ID(); $user_id = get_current_user_id(); $is_enrolled = sfwd_lms_has_access($course_id, $user_id); $course_url = get_permalink($course_id); // Get first lesson URL $lessons = learndash_get_course_lessons_list($course_id); $first_lesson_url = !empty($lessons[0][‘permalink’]) ? $lessons[0][‘permalink’] :…Continue reading
function custom_redirect_root_and_dashboard() { $current_path = trim(parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH), ‘/’); // Detect language (e.g., ‘en’, ‘ar’, etc.) $parts = explode(‘/’, $current_path); $lang = $parts[0] ?? ”; $page = $parts[1] ?? ”; // Handle multilingual root like “/en/” $is_root_homepage = empty($current_path) || (count($parts)…Continue reading
add_action( ‘wp_head’, function() { ?>Continue reading
function mepr_cust_no_vat_to_taxjar( $should_send, $event ) { $transaction = $event->get_data(); if ( strpos( $transaction->tax_desc, __( ‘VAT’, ‘memberpress’ ) ) !== false ) { $should_send = false; } return $should_send; } add_filter( ‘mepr_taxjar_should_send_txn’, ‘mepr_cust_no_vat_to_taxjar’, 10, 2 );Continue reading
function mepr_dequeue_wpforms_on_register_page() { global $post; $is_product_page = ( false !== ( $prd = \MeprProduct::is_product_page($post) ) ); $is_account_page = \MeprUser::is_account_page($post); if($is_product_page || $is_account_page) { wp_deregister_script( ‘wpforms-smart-phone-field’ ); wp_dequeue_script( ‘wpforms-smart-phone-field’ ); } } add_action( ‘wpforms_frontend_js’, ‘mepr_dequeue_wpforms_on_register_page’, 9999 );Continue reading
/* WordPress */ function prevent_apostrophe_in_email($errors, $sanitized_user_login, $user_email) { if (strpos($user_email, “‘”) !== false) { $errors->add(‘invalid_email’, __(‘Error: Email addresses cannot contain apostrophes.’, ‘mytheme’)); } } add_filter(‘registration_errors’, ‘prevent_apostrophe_in_email’, 10, 3); /* WooCommerce */ function prevent_apostrophe_in_checkout($posted) { if (isset($posted[‘billing_email’]) && strpos($posted[‘billing_email’], “‘”) !==…Continue reading
function mepr_custom_send_mailpoet_confirm($request_args) { $request_args[‘send_confirmation_email’] = true; return $request_args; } add_filter(‘mepr-mailpoet-subscribe-args’, ‘mepr_custom_send_mailpoet_confirm’);Continue reading
add_action(‘mepr-event-subscription-expired’, function($event) { $txn = $event->get_data(); // Get the transaction data from the event $user = $txn->user(); // Get the user associated with the transaction // Check if the expired subscription is for the specific membership if ($txn->product_id == ‘123’)…Continue reading
add_action(‘mepr-event-subscription-stopped’, function($event) { $subscription = $event->get_data(); if(123 != (int) $subscription->product_id) { return; } $user = $subscription->user(); $wp_user = get_user_by(‘id’, $user->ID); if(!$wp_user) { return; } // Remove role $wp_user->remove_role( ‘subscriber’ ); // Add role $wp_user->add_role( ‘editor’ ); });Continue reading