Assign User Role Conditionally in WordPress

/** * Assigns a specific WordPress user role based on the selected value in a WPForms multiple-choice field. * * @link https://wpforms.com/how-to-assign-user-roles-conditionally-in-wordpress/ * * @param array $user_data Array containing user registration data. * @param array $fields Array of form fields…Continue reading

Vendor & Venue Posts: Sync Target Market Fields with Location Taxonomy

// Gravity Forms hook for form 5 (vendor) add_action(‘gform_after_submission_5’, function ($entry, $form) { $post_id = rgar($entry, ‘1’); if (!$post_id || get_post_type($post_id) !== ‘vendor’) return; // Check if the required meta fields exist if (!get_post_meta($post_id, ‘target_market_1_city’, true)) return; // Update taxonomy…Continue reading

WordPress Post Views Counter Function

function wpb_set_post_views($postID) { $count_key = ‘wpb_post_views_count’; $count = get_post_meta($postID, $count_key, true); if($count==”){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, ‘0’); }else{ $count++; update_post_meta($postID, $count_key, $count); } } //Get rid of prefetching to keep the count accurate remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10,…Continue reading

Completely Disable Comments (copy) (copy)

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Completely Disable Comments (copy)

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Subscription Management (Testing)

// Save Stripe Customer ID to user meta upon user registration add_action( ‘gform_after_submission’, function ( $entry, $form ) { $form_ids = array(3,4,12); if ( ! in_array( (int)$form[‘id’], $form_ids, true ) ) { return; } // Retrieve the Stripe Customer ID…Continue reading

KayBee AG – Webhook on Order Payment Complete

add_action( ‘woocommerce_order_status_processing’, ‘rudr_complete’ ); function rudr_complete( $order_id ) { $order = wc_get_order( $order_id ); //$order_data = $order->get_data(); $msg = [ ‘order_id’ => $order_id, ‘site’ => get_site_url() ]; $webhook_url = ‘https://server.bergwerk.li:9000/hooks/kaybee-woocommerce-palos’; //$webhook_url = ‘https://eo9dxhypahm1gsc.m.pipedream.net’; $headers = array(‘Content-Type: application/json’); $ch = curl_init();…Continue reading