The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
How to Prevent Gues...
 
Share:
Notifications
Clear all

[Solved] How to Prevent Guests from Using Registered Users' Email Addresses

1 Posts
1 Users
0 Reactions
18 Views
Asti
 Asti
(@asti)
Illustrious Member Support
Joined: 7 years ago
Posts: 7789
Topic starter  

Starting from version 7.6.28, a new hook "wpdiscuz_before_wp_new_comment", has been added.Β 

This action allows you to perform tasks based on comment data. For example, you can use it to prevent guests from using registered users’ email addresses.

To achieve this, use the following hook code:

add_action("wpdiscuz_before_wp_new_comment", function($commentdata){
    if (!empty($commentdata["comment_author_email"]) && empty($commentdata["user_id"])) {
        $is_user_exist = get_user_by("email", sanitize_text_field($commentdata["comment_author_email"]));

        if ($is_user_exist) {
            wp_die(esc_html__("A user with this email is already registered! Please log in or use a different one!", "wpdiscuz"));
        }
    }
});

The red-marked text can be customized as needed.

For a step-by-step guide on adding custom code to WordPress without breaking your site, check out this article: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

Β 

This topic was modified 1 day ago by Asti

In case you want to say thank you! πŸ™‚
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.


   
Share: