正文

WHMCS教程-未验证邮箱用户限制操作

WHMCS教程-未验证邮箱用户限制操作

文件下载:PreventOrdersFromUnverifiedAccounts

使用方法:

首先:系统设置-常规设置-安全,里面勾选上“用户注册或更改邮箱时需要验证邮箱地址”

WHMCS教程-未验证邮箱用户限制操作WHMCS教程-未验证邮箱用户限制操作

然后要配置好邮件SMTP服务,就是说你系统起码得能让人接收你的验证码来验证是不是。

然后将文件放到:/includes/hooks这个目录内,如果没有这些目录的,自己创建!

效果预览:在结账生成账单前会提示验证邮箱。没验证的话会提交不了账单

WHMCS教程-未验证邮箱用户限制操作WHMCS教程-未验证邮箱用户限制操作

 

可配置参数:直接在文件源码里自己修改即可。切记,如无必要的话不要轻易停止账户。这不符合国内用户的习惯。建议是默认就好,默认只限制订购操作。

# 请问是否禁止未验证账户的产品购买下单操作,true为是,false为否
define(“PREVENTUNVERIFIEDORDERS", true);

# 在账户未验证几天后停用账户?0则为不停用
define(“DEACTIVATEACCOUNTAFTERXDAYS", 0);

# 在账户未验证几天后关闭账户?0则为不关闭

 

自行测试是否有病毒。

源码:

<?php
/**
 * 未验证邮箱的用户进行限制操作HOOKS
 */

if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

# 请问是否禁止未验证账户的产品购买下单操作,true为是,false为否
define("PREVENTUNVERIFIEDORDERS", true);

# 在账户未验证几天后停用账户?0则为不停用
define("DEACTIVATEACCOUNTAFTERXDAYS", 0);

# 在账户未验证几天后关闭账户?0则为不关闭
define("CLOSEACCOUNTAFTERXDAYS", 0);


# No Orders Will be Completed
add_hook("ShoppingCartValidateCheckout", 1, function($vars){
    
    if (PREVENTUNVERIFIEDORDERS===true){
        
        $client = Menu::context("client");
        
        if (!is_null($client) && $client->emailVerified!==true){
            return array("系统提醒:您必须先验证邮箱,然后才能完成此订单!");
        }
        
    }
    
});

# Deactivate Unverified Account After x Days
# 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"));
        }
        
    }
});

# Close Unverified Accounts After X Days
# 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"));
        }
        
    }
    
});