Please add below code into your current theme’s function.php
function custom_validate_city() {
if( empty($_POST[ 'city' ])) // do you url validation here (I am not a regex expert)
wp_die( __('Error: please enter a city') );
}
add_action('pre_comment_on_post', 'custom_validate_city');
Related Posts:
- How to display custom field in woocommerce orders in admin panel?
- Programatically add options to “add new” custom field dropdown
- Get a list of all available fields in the User Profile
- Enabling shortcodes for custom fields
- Add options to featured image
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Assign category using custom field?
- Function to Download External Images to My Site
- Checked() showing up twice in custom fields
- How to use max and min values of custom fields
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Customizer field value into functions.php variable
- Auto delete post if certain custom field data is empty
- How to display custom option field in woocommerce orders in admin panel?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- What WordPress function to use to get meta value by using meta keys?
- Removing custom meta data
- Change label for registration Fields
- Custom Attachment Caption Fields
- Default Custom Field Value Automatically Update
- WordPress function saves a post twice and updates all posts
- ACF not showing
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- How to get correct value from checked()?
- Prevent custom field from being updated after first publish
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Programmatically add Yoast meta description after post save
- Insert Address fields into function
- How add body_class from wp_termmeta
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- Sort and display pages with specific custom field (not tag)
- shorthand syntax for custom fields
- Fill empty custom field with other custom field
- Perform function on publish AND save (not just save)
- Output comment_author in array
- How to Display WooCommerce Product Price in WooCommerce Archive
- How to change text color depending on the number value (Using javascript)
- WordPress comment processing . Default unapproved comments detection before posting
- wp_set_object_term via js btn frontend
- How do I make the comment disappear after deleting from the database?
- Populate Product Regular Price with a calculated ACF Field Value
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Create New User Custom Field not Saving
- Creating a “Related Meta” type field?
- How would I correctly implement a new if statement in a child functions file?
- Hide empty custom field
- How To Show Shortcodes In WordPress Custom Fields?
- How to echo the translated custom field?
- How to add function to custom fields when page/post has a password?
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- Post date on Custom field
- Dynamically generated Navigation Diagram using Custom Fields
- Define an extra field for all pages (with no plugin?)
- update_post_meta not working in function
- Adding custom field in menu options [duplicate]
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- How to display data from custom fields in my custom shortcode?
- Syling Custom Fields echo’s from from functions.php
- Add custom fields after post/page title
- Adding and updating repeating custom field meta data
- Change Post status based on custom field date +1 day
- Wanted to get rid of Paragrapgh tag in submit buttom of the WordPress form
- Post meta not updating
- Check if Page Slug Exists, then display that Page’s Title
- Why doesn’t is_page(id) work in functions.php?
- Function to alphabetically sort custom post types creating duplicates
- get_post_meta() problem again
- Update users custom profile fields
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Add back in child theme what the parent theme removed with remove_action
- replace text in Sort Box
- Prevent loading of functions
- call_user_func_array() expects parameter 1 to be a valid callback, function
- video.js not enqueueing?
- Removing WPML Items From the WordPress Admin Bar
- Override a Post’s URL with Advanced Custom Fields Function
- Passing function arguments via a shortcode
- Is it possible to update the dataset using update_post_meta
- Widget is displayed in two places
- Wildcard 301 Redirect Using Theme Function
- Link to an externally created photo albums
- How to identify author in wordpress comments?
- Which method is more correct for removing WooCommerce Extensions menu item?
- Why does Featured Images not load in the backed?
- Help! Need a different logo on my main page from my other pages
- RSS feed including post updates
- How to add meta fields to custom taxonomy add/edit page?
- WordPress not showing pagination links
- Automatically add tag if a checkbox is checked
- How to add a meta information to the URL?
- Why wp_ajax hooks doesn’t work?
- How to assign a div class to a echo function [closed]
- How can I add authors to my blog pages?
- Getting error on function.php
- delete_term is not working properly with add_action()
- Add URL parameter to nav links based on domain
- hide div if empty
- How to display a function inside shortcode tags