function preprocess_mycomment($commentdata) {
$existing_comments = get_comments( array('post_id' => 31691) ); // I run the code for one specific page only
foreach ($existing_comments as $comment) {
$previous_comments = $comment->comment_author_email; // email address send by the current poster
if ( $previous_comments == $commentdata['comment_author_email'] ) { // comparing the current email address with the previous ones in database.
wp_die('The email ' . $previous_comments . ' has already been used.');
}
}
return $commentdata;
}
add_filter('preprocess_comment', 'preprocess_mycomment');
Related Posts:
- Sending data from custom inputs in WordPress comment form in the admin notification email
- edit_comment_link is not showing for comment author
- Add custom field on admin dashboard comments / reviews
- what is correct way to hook when update post
- Using register_activation_hook in classes
- WordPress and event-driven programming – what is it about?
- Remove Woocommerce product link
- Display user’s total comment count outside The Loop
- Facebook Comment Count
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to remove a metabox from menu editor page?
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- Check if page parent has certain template
- Prevent publish status/date saved on transition_post_status hook
- How to Remove a Filter from the Admin List Table?
- How do I create comment-reply-button using element not
- Woocommerce, recognize the loop of related products
- How to check if comments are paginated?
- Executing `createimagefrompng()` from save_post hook (or equivalent hook)
- Getting my head round WordPress filter
- Delete option value from array using update_option()
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- How To Change The Html of Products filtration sidebar in Woocommerce?
- Automatically generate Post/Page from searched Database item?
- How to set a custom path, for ajax image upload folder in admin?
- Insert all post IDs in new database table
- How to add a second ‘place order’ button in WooCommerce [closed]
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- wp_loaded hook block script enquequing
- Show comments menu in dashboard only if the site has comment
- hook that when page is starting to load
- How to change home or site url using action hooks or filter?
- Trying to build simple deposit code that hooks into woocommerce
- Add a product to checkout via form
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- user_profile_update_errors hook not executing
- How to add an arrow to menu items has submenus
- Return a numerical function value in Customizer controls
- Adding function to Genesis genesis_header [closed]
- Genesis framework comments broken?
- Get post id within comments loop
- Password minimum length in personal subscription [closed]
- Run a code only on theme activation only during first activation
- Theme activation hook in php class
- WordPress comment submit button substitutes/options
- How to list commenters and days since last commented
- How to add text to the start of all comments?
- Appended comments but they show up above the content instead of below
- get comment data using comment id
- wp_delete_comment takes two tries to delete – then deletes all comments
- How to catch wordpress post ID when it’s published
- Change “No Comments” link to “My String” on Blog Post (Find Snippet in Code or use CSS, PHP Solution) [closed]
- How can I hook into the wp_mail function used by BackWPup?
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- get_comments_number() returns 0
- Must filter functions receive all arguments passed to them?
- Generate a QR code when creating a new WordPress user
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Display custom field value in woocommerce variable product via jQurey
- Use wp_head hook on template page
- How to pass parameters in wordpress shortcode?
- Display the list of user’s comments + the post title + date
- Adding custom field to product category and show it to shop/category shop page
- Preserving backslashes in post_content
- How to edit post meta data before publishing the post it self wordpress?
- Enqueue assets from multiple directories using add_action/do_action
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Call a single function on two different methods with hooks
- Discount in the specific product title using keyword ( Woocoommerce )
- Comments on my custom post type
- get Woocommerce product format json for WP_Query
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- Hook into all password resets in WordPress and get password before hashing?
- How to add delete, approve, spam Links to Comments
- Real time notification on user profile after new comment
- Why transition_post_type hook is called twice for the same post?
- What’s the correct offset value for order ASC?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- Passing link parameter values to form
- Getting most popular posts based on Facebook comments count
- WordPress HTML Helper
- A Space being added to url generated by custom plugin
- Custom action on comment post
- How to add custom checkout field in user details mail template
- How to get the rating value of each comment
- Trouble figuring out how to get my button to submit comment
- How to convert my comment.html to comment.php
- For each loop will not append to the_content hook
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- understanding wp_next_scheduled
- transition_post_status hook, works – but not if the post is new
- Permissions error when I use my plugin to delete comments in the front-end
- Woocommerce – add tracking code to another email template