Topic starter
21/02/2025 10:00 am
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.