Archives: Snippets
Lang
document.addEventListener(“DOMContentLoaded”, function() { const flowchart = document.getElementById(“flowchart”); flowchart.innerHTML = ` How do you plan to use your Lang BBQ Smoker? Residential Competition Commercial What cooking capacity do you need? Small (36” Patio) Large (48” or larger) Back Do you need…Continue reading
woo orders page Whatsapp DM from mac app
// Modify the columns and ensure WhatsApp column appears last function add_whatsapp_column($columns) { // Remove WhatsApp column if it already exists if (isset($columns[‘whatsapp’])) { unset($columns[‘whatsapp’]); } // Add WhatsApp column after Courier Address column if (isset($columns[‘courier_address’])) { $new_columns = [];…Continue reading
woo orders page courier address
// Add the new column to the orders page add_filter(‘manage_edit-shop_order_columns’, ‘display_courier_address_column’); // Display data in the new column add_action(‘manage_shop_order_posts_custom_column’, ‘display_courier_address_data’, 10, 2); function display_courier_address_column($columns) { // Add the new column with a proper name $columns[‘courier_address’] = ‘Courier Address’; return $columns;…Continue reading
Untitled Snippet
MemberPress: Change the Member’s User Role After Subscription Cancellation
add_action(‘mepr-event-subscription-stopped’, function($event) { $subscription = $event->get_data(); $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
MemberPress: Allow a User Role to Access the Admin Area
// allow Editors to access Memberpress function add_memberpress(){ $role = get_role(‘editor’); $role->add_cap(‘remove_users’); } add_action(‘admin_init’,’add_memberpress’);Continue reading
MemberPress: Allow Importing Coupons Associated With Affiliates (Easy Affiliate)
function mpimp_load_expanded_coupon_importer() { global $mpimp; $mpimp->importers[‘couponaffiliate’] = ‘MpimpExtendedCouponsImporter’; } add_action(‘admin_init’, ‘mpimp_load_expanded_coupon_importer’, 110); //has to be after the MP hook function runs class MpimpExtendedCouponsImporter extends MpimpCouponsImporter { public function form() { } public function import($row,$args) { $ea_active = is_plugin_active(‘easy-affiliate/easy-affiliate.php’) ? true…Continue reading
MemberPress: Auto Approve Sub-Accounts with New User Approve Plugin
function mepr_newuser_approve_override($user_id) { // Define an array of membership IDs for which the verification step should be skipped. $auto_approve = array(123, 456, 789); if(!class_exists(‘MeprOptions’)) { return; } if(!isset($_POST[‘mepr_product_id’]) && !isset($_POST[‘manage_sub_accounts_form’])) { return $user_id; } $product_id = isset($_POST[‘mepr_product_id’])?$_POST[‘mepr_product_id’]:false; if(isset($_POST[‘manage_sub_accounts_form’]) || ($product_id…Continue reading
MemberPress: Display User’s Course Progress in MemberPress Courses
add_shortcode( ‘mpcs_user_courses_progress’, function() { $user_id = get_current_user_id(); $courses = get_posts(array( ‘posts_per_page’ => -1, ‘post_type’ => ‘mpcs-course’ )); ob_start(); echo ‘ ‘; foreach ( $courses as $course ) { $course = new memberpress\courses\models\Course($course->ID); $progress = $course->user_progress($user_id); if ( $progress < 100…Continue reading