sentq Posted May 13, 2016 Share Posted May 13, 2016 These ActionHook functions will add some restrictions to unverified accounts. Current features: 1) Prevent account from placing orders in WHMCS, and display error message guide them to activate first. 2) Change account status to Inactive after x days. 3) Change account status to Closed after x days. Do not hesitate to share any ideas, requests or features to extend this functions. Download 0 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted May 24, 2016 Share Posted May 24, 2016 (edited) Thanks for sharing. I'm new to hooks - Do you know how I can check if email verification has been completed in an action hook? I'm not using capsule, so would this code still work? if (!is_null($client) && $client->emailVerified!==true){ Also, a suggestion for you, rather than CLOSEACCOUNTAFTERXDAYS how about a resendverification afterxdays function (I don't think the system does that). I suppose you'd need to apply the resend only to newly created accounts. Edited May 24, 2016 by sol2010 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 24, 2016 Author Share Posted May 24, 2016 Thanks for sharing. I'm new to hooks - Do you know how I can check if email verification has been completed in an action hook? I'm not using capsule, so would this code still work? if (!is_null($client) && $client->emailVerified!==true){ you may use something like that use WHMCS\View\Menu\Item as MenuItem; $client = Menu::context("client"); if (!is_null($client) && $client->emailVerified===true){ // Client email verified } else { // Client email not verified yet or not logged-in } Also, a suggestion for you, rather than CLOSEACCOUNTAFTERXDAYS how about a resendverification afterxdays function (I don't think the system does that). I suppose you'd need to apply the resend only to newly created accounts. I will add it as optional function in the next update Thank you 0 Quote Link to comment Share on other sites More sharing options...
Aqib2001 Posted July 4, 2018 Share Posted July 4, 2018 On 5/14/2016 at 3:28 AM, sentq said: These ActionHook functions will add some restrictions to unverified accounts. Current features: 1) Prevent account from placing orders in WHMCS, and display error message guide them to activate first. 2) Change account status to Inactive after x days. 3) Change account status to Closed after x days. Do not hesitate to share any ideas, requests or features to extend this functions. Download Thanks, but i am not able to download it. I am receiving 404 Page Not Found Error. 0 Quote Link to comment Share on other sites More sharing options...
Hostify Posted August 29, 2018 Share Posted August 29, 2018 On 5/14/2016 at 12:28 AM, sentq said: These ActionHook functions will add some restrictions to unverified accounts. Current features: 1) Prevent account from placing orders in WHMCS, and display error message guide them to activate first. 2) Change account status to Inactive after x days. 3) Change account status to Closed after x days. Do not hesitate to share any ideas, requests or features to extend this functions. Download Can you please share a new URL? This one is broken, i get a 404 Not Found Pagehttp://nimb.ws/ohF17L 0 Quote Link to comment Share on other sites More sharing options...
Manchester Web Hosting Posted August 30, 2018 Share Posted August 30, 2018 @Hostify 19 hours ago, Hostify said: Can you please share a new URL? This one is broken, i get a 404 Not Found Pagehttp://nimb.ws/ohF17L You can go here to download: https://www.whmcms.com/download/category/6/WHMCS-Free-Addon-Modules-and-Action-Hooks.html Hope the OG poster doesn't mind! 0 Quote Link to comment Share on other sites More sharing options...
JesusSuarz Posted January 18, 2021 Share Posted January 18, 2021 On 5/13/2016 at 5:28 PM, sentq said: These ActionHook functions will add some restrictions to unverified accounts. Current features: 1) Prevent account from placing orders in WHMCS, and display error message guide them to activate first. 2) Change account status to Inactive after x days. 3) Change account status to Closed after x days. Do not hesitate to share any ideas, requests or features to extend this functions. Download after checking this. I see that it does not work. could you check the code? apparently stopped working for whmcs v8 I want them to not be able to order. (If the email is not verified then it will not allow you to place the order) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 18, 2021 Share Posted January 18, 2021 3 hours ago, JesusSuarz said: after checking this. I see that it does not work. could you check the code? apparently stopped working for whmcs v8 going by the v8 class docs, I assume it should now be $client->isEmailAddressVerified rather than $client->emailVerified 0 Quote Link to comment Share on other sites More sharing options...
JesusSuarz Posted January 22, 2021 Share Posted January 22, 2021 (edited) On 1/18/2021 at 11:37 AM, brian! said: going by the v8 class docs, I assume it should now be $client->isEmailAddressVerified rather than $client->emailVerified after checking $client with a var_dump I realized that neither of the 2 options would work. neither emailVerified nor isEmailAddressVerified I had to use: email_verified_at email_verified_at returns the value in bool, which is null or true. here I leave the new code. <?php /** * Limit Access For Unverified Accounts * @package WHMCS ActionHook * @author Sentq <sales@whmcms.com> and JesusSuarz <info@cangurohosting.com> * @copyright Copyright (c) CanguroHosting.com 2016-2021 * @link http://www.whmcms.com/ */ if (!defined("WHMCS")) die("This file cannot be accessed directly"); use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # ¿Le gustaría evitar que las cuentas no verificadas realicen pedidos ?, configúrelo en falso para aceptar pedidos define("PREVENTUNVERIFIEDORDERS", true); # Cuántos días esperar antes de desactivar la cuenta no verificada, establezca 0 para desactivar esta función define("DEACTIVATEACCOUNTAFTERXDAYS", 0); # Cuántos días esperar antes de establecer la cuenta no verificada como cerrada, establecer 0 para deshabilitar esta función define("CLOSEACCOUNTAFTERXDAYS", 0); # No se completarán pedidos si el correo no esta verificado. add_hook("ShoppingCartValidateCheckout", 1, function($vars){ if (PREVENTUNVERIFIEDORDERS===true){ $client = Menu::context("client"); if (!is_null($client) && $client->email_verified_at!==true){ return array("¡Primero debe verificar su dirección de correo electrónico antes de completar cualquier pedido!"); } } }); # Desactivar la cuenta no verificada después de x días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(DEACTIVATEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(DEACTIVATEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Inactive")); } } }); # Cerrar cuentas no verificadas después de X días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(CLOSEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(CLOSEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Closed")); } } }); This is executed after accepting the terms in the payment options in: your_whmcs.com/cart.php?a=checkout screenshot Edited January 22, 2021 by JesusSuarz 0 Quote Link to comment Share on other sites More sharing options...
JesusSuarz Posted January 22, 2021 Share Posted January 22, 2021 1 hour ago, JesusSuarz said: after checking $client with a var_dump I realized that neither of the 2 options would work. neither emailVerified nor isEmailAddressVerified I had to use: email_verified_at email_verified_at returns the value in bool, which is null or true. here I leave the new code. <?php /** * Limit Access For Unverified Accounts * @package WHMCS ActionHook * @author Sentq <sales@whmcms.com> and JesusSuarz <info@cangurohosting.com> * @copyright Copyright (c) CanguroHosting.com 2016-2021 * @link http://www.whmcms.com/ */ if (!defined("WHMCS")) die("This file cannot be accessed directly"); use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # ¿Le gustaría evitar que las cuentas no verificadas realicen pedidos ?, configúrelo en falso para aceptar pedidos define("PREVENTUNVERIFIEDORDERS", true); # Cuántos días esperar antes de desactivar la cuenta no verificada, establezca 0 para desactivar esta función define("DEACTIVATEACCOUNTAFTERXDAYS", 0); # Cuántos días esperar antes de establecer la cuenta no verificada como cerrada, establecer 0 para deshabilitar esta función define("CLOSEACCOUNTAFTERXDAYS", 0); # No se completarán pedidos si el correo no esta verificado. add_hook("ShoppingCartValidateCheckout", 1, function($vars){ if (PREVENTUNVERIFIEDORDERS===true){ $client = Menu::context("client"); if (!is_null($client) && $client->email_verified_at!==true){ return array("¡Primero debe verificar su dirección de correo electrónico antes de completar cualquier pedido!"); } } }); # Desactivar la cuenta no verificada después de x días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(DEACTIVATEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(DEACTIVATEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Inactive")); } } }); # Cerrar cuentas no verificadas después de X días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(CLOSEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(CLOSEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Closed")); } } }); This is executed after accepting the terms in the payment options in: your_whmcs.com/cart.php?a=checkout screenshot after doing hundreds of tests I was able to identify that emailVerified does work. therefore the original script did work. my problem was the user I was using, it was modified directly in my database. therefore the @Sentq script works fine. I apologize for posting wrongly. 0 Quote Link to comment Share on other sites More sharing options...
JesusSuarz Posted February 5, 2021 Share Posted February 5, 2021 On 1/18/2021 at 11:37 AM, brian! said: going by the v8 class docs, I assume it should now be $client->isEmailAddressVerified rather than $client->emailVerified you were right, although it was $client->isEmailAddressVerified() the () were missing at the end. here is a new version of the code written. the texts are in Spanish, sorry. 🙂 Quote <?php if (!defined("WHMCS")) die("No se puede acceder al archivo directamente!"); use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # ¿Le gustaría evitar que las cuentas no verificadas realicen pedidos ?, configúrelo en falso para aceptar pedidos define("PREVENTUNVERIFIEDORDERS", true); # Cuántos días esperar antes de desactivar la cuenta no verificada, establezca 0 para desactivar esta función define("DEACTIVATEACCOUNTAFTERXDAYS", 365); # Cuántos días esperar antes de establecer la cuenta no verificada como cerrada, establecer 0 para deshabilitar esta función define("CLOSEACCOUNTAFTERXDAYS", 0); # No se completarán pedidos si el correo no esta verificado. add_hook("ShoppingCartValidateCheckout", 1, function($vars){ if (PREVENTUNVERIFIEDORDERS===true){ // obtiene los datos del client $client = Menu::context("client"); // verifica si el cliente esta logeado y si se encuentra if (!is_null($client) && $client) { // verifica si el email no esta verificado if ($client->isEmailAddressVerified()==false) { // mensaje return array("<b>¡Primero debe verificar su dirección de correo electrónico antes de completar cualquier pedido!</b>"); } } } }); # Desactivar la cuenta no verificada después de x días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(DEACTIVATEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(DEACTIVATEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Inactive")); } } }); # Cerrar cuentas no verificadas después de X días # http://docs.whmcs.com/Clients:Profile_Tab#Changing_a_Clients_Status add_hook("DailyCronJob", 1, function($vars){ if (intval(CLOSEACCOUNTAFTERXDAYS)!==0){ $dateCreated = date("Y-m-d", strtotime("now - ".intval(CLOSEACCOUNTAFTERXDAYS)." days")); $getAccounts = Capsule::table("tblclients")->where("datecreated", "=", $dateCreated)->where("email_verified", "=", 0); foreach ($getAccounts->get() as $account){ Capsule::table("tblclients")->where("id", $account->id)->update(array("status" => "Closed")); } } }); 1 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted February 6, 2021 Share Posted February 6, 2021 Great work & thanks for sharing. It is just a pity you have to do this to start with instead of it being part of the product - it is such a useful feature but WHMCS managed to implement it in such a way as to make their implementation pointless! 0 Quote Link to comment Share on other sites More sharing options...
Mike Vassileiou Posted November 28, 2021 Share Posted November 28, 2021 JesusSuarz your hook wokrs great!!! Thanks!!! I have modified its output a little bit, using language file for the output message: // mensaje global $_LANG; return $_LANG['verifyEmailAddress']; 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.