MFP > Client Utilities

/** * ERC Utilities * */ function get_Cid($s_id, $user_id, $insert = null) { if (!$s_id || !$user_id) return null; $user = new WP_User($user_id); // if (!in_array(‘client’, $user->roles)) return null; $show = get_city($s_id) . ‘ ‘ . get_year($s_id); $loop = new…Continue reading

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