Email validation & Spam control


 Is there a plugin where i can limit the validation time of users to 24hours after which the validation should get failed & the validation data should also be deleted.

I want registration email of user to be of certain domain only registration from other domain should be rejected. say only from gmail,yahoo & hotmail alone rest of the domain registration should be rejected. 

  • You can setup a cron job that will delete all users that are not validated within 24 hours.

    For domain throttling, just register a hook for 'action', 'register' and deny if email is in the wrong domain.

  •     // Delete all user accounts that have been disabled by uservalidationbyemail plugin
        // that were created more than 24 hours ago
        elgg_register_plugin_hook_handler('cron', 'hourly', function() {
            $ha = access_get_show_hidden_status();
            $ia = elgg_set_ignore_access();
            $time = time() - 24 * 60 * 60; // 24 hours ago
            $users = elgg_get_entities_from_metadata([
                'types' => 'user',
                'metadata_name_values_pairs' => [
                    'name' => 'disable_reason',
                    'value' => 'uservalidationbyemail_new_user',
                'wheres' => [
                    "e.time_created <= $time",
                    "e.enabled = 'no'",
                'limit' => 0,
                'batch' => true,
            foreach ($users as $user) {
  •     // Set early priority, so this is triggered before uservalidationbyemail kicks in
        elgg_register_plugin_hook_handler('register', 'user', function($hook, $type, $return, $params) {
            if ($return === false) {
                // something else prevented registration
            $user = elgg_extract('user', $params);
            if (!$user) {
            $email = $user->email;
            list($prefix, $domain) = explode('@', $email, 2);
            $blacklisted_domains = [
            if (in_array($domain, $blacklisted_domains)) {
                register_error("Emails from $domain domain are not allowed to register");
                return false;
        }, 100);
  • In the future, do not use pages to ask question. Go to a respective group and start a discussion. One question - one discussion.

  • Thank you ismail for your reply .. Oh sorry my mistake i thought it is a discussion i am opening bad eye ..

  • Take a look at regarding restrictions on allowed email domains.

  • The hook used in Daniel's link is more suitable for email validation, but the approach is the same.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking