Jump to content

How to? Hook that prevents emails to be sent based on client group


Recommended Posts

Hello there

Wile waiting for a third module setting up, I am looking if any hook can do this workaround and can get me closer.

I want to create new client group (ex. named IT2020), and have a hook that prevents 3 things:


1   - image.png.25e3e96d0f69e52771b65db0f248ec30.png(prevent that message to sent out, even if I forgot to un-tick it)

2   -  image.png.f245fa4b6a2319c51f36f847e8fe56eb.png       (Auto disallow single sign-on, even if it get tick)

3  -   image.png.7a9b0765ad15f734df88f13306185bc4.png  (Auto disallow Marketing email even if it get tick)

Actually I do not know if even hook can abort those specific action at ounce based on client group 😷

PS: hook should work based on client group IT2020.
 

thank you!

Link to comment
Share on other sites

<?php

use WHMCS\Database\Capsule;

add_hook('EmailPreSend', 1, function($vars)
{
    $disallowedGroupID = '1'; // Insert Client Group ID
    $emailTemplates = array('Automated Password Reset', 'Password Reset Validation', 'Password Reset Confirmation'); // Email Templates to block

    if (in_array($vars['messagename'], $emailTemplates))
    {
        if (!Capsule::select(Capsule::raw('SELECT id FROM tblclients WHERE id = "' . $vars['relid'] . '" AND groupid = "' . $groupid . '" LIMIT 1')))
        {
            $output['abortsend'] = true;
            return $output;
        }
    }
});

This will block any email template you want but at the moment I can't remember how to block Marketing & Sign-On emails.

Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated