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
- Adding a second email address to a completed order in WooCommerce [closed]
- Advantages and disadvantages of using automatic-feed-links
- Change meta tags programatically
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- Use a function to update post meta based on other post meta
- Adding body class when post contains a specific shortcode
- Displaying Widgets
- Display WooCommerce subscriptions for user [closed]
- How To Remove Duplicate Menu Locations
- Show top commenters without using a plugin
- Post thumbnail not showing in WP admin area for custom post type
- Backstretch.js and thumbnail sizes to reduce loading time
- Child theme within a child theme?
- Featured Image Thumbnail Creation
- Updating Media Published Date When Parent Post Is Modified in WordPress
- WP Ajax Function Always Returning undefined
- How can I grab the video id of youtube?
- Passing variable as add_shortcode argument
- ACF in wordpress
- add_action wp_enqueue_script priority level only works for admins
- current_user_can comma list vs OR (||) list
- Writing a function to detect an event
- Problem with calling custom function in a foreach loop
- Add a mature content warning to first-time visitors
- wordpress built-in Jalali date convertor
- WordPress Function Assistance with Loop
- Populate acf-field, depending on block name
- Add Change role button for list of user in an event
- I am trying to set post terms to a custom taxonomy
- Classic TinyMCE messing up only Contributor’s HTML
- Add schema to Search result page’s body. Tried using is_search
- WordPress Javascript Widget jQuery Dependency Issue
- Allow tags and attributes in post and pages content
- Syntax for a function in order to get post’s title in JSON encoded response [closed]
- Comment Function
- How to overwrite image if it already exists – WordPress, Gravity form
- Change TinyMCE undeline outpout