Jump to content

Limit Client registration


Dhush

Recommended Posts

With stock (default) whmcs? No, this is not possible

However, it's not terribly hard to whip up a hook to do this. Here you go.

 

Step 1: Save the following as whmcs/includes/hooks/registrationlimit.php . Make sure to edit the $reglimit variable to your taste. I set it at 5 to test and ensure that it worked.

This will add one query to every page load that an unregistered user makes. Pretty light, honestly

<?php
use Illuminate\Database\Capsule\Manager as Capsule;
function client_registration_limit($vars)
{
$displayTitle = $vars['displayTitle'];

//how many clients do we allow? Specify here
$reglimit = '100';


//do we already have a registered account? Then we do nothing else
$uid  = $_SESSION['uid'];
if (!empty($uid))
{
	return;
}

	//assign the variable here
	$rows = Capsule::table('tblclients')->select('id') ->WHERE ('status', '=', 'Active')  ->count();
	if ($rows >= $reglimit)
	{
		$return = array();
		$return = array("noregister" => "TRUE");
		return $return;
	}


}

add_hook('ClientAreaPage', 1, "client_registration_limit");

 

 

 

Step two:

in whmcs/lang/overrides (if the directory doesnt exist, create it), add english.php, renaming to your language, of course. Again, adjust language to your taste. This is only an example


<?php
/*language file for the whmcs hooks*/

$_LANG['clientareregistrationlocked'] = "Client registration is temporarily disabled, as we are at capacity. Please try again at a later time<p>If you are already registered, please <a href=\"./login.php\">Login</a> to order services from us</p>";

?>

 

Step 3: in your whmcs/templates/yourtemplate/ directory, add a file named clientnoregister.tpl with the following:


<div class="row">
               <div class="col-md-6 col-md-offset-3">
                       <div class="panel panel-danger">
                               <div class="panel-heading">
                                               <h3 class="panel-title">{$LANG.clientregistertitle}</h3>
                               </div>
                               <div class="panel-body">
                                       <p>{$LANG.clientareregistrationlocked}</p>
                               </div>
                               <div class="panel-footer">
                                       <a href="clientarea.php?action=productdetails&id={$id}" class="btn res-100 btn-3d btn-primary">{$LANG.clientareabacklink}</a>
                               </div>
                       </div>
               </div>
       </div>

 

Step 4:at the top of whmcs/templates/yourtemplate/clientregister.tpl, before anything else, add

{if $noregister}
               {include file="$template/clientnoregister.tpl"}
{else}

 

Step 5: At the bottom of whmcs/templates/yourtemplate/clientregister, after everything else, add

{/if}

 

Step 6: repeat steps 4 and 5 for your orderform , in whmcs/templates/orderforms/yourorderform/checkout.tpl . If whmcs/templates/orderforms/yourorderform/checkout.tpl doesn't exist, then apply the changes to whmcs/templates/orderforms/standard_cart/checkout.tpl

 

You want to make sure that you save your orderforms and template to a new template and orderform, and select those to be used, to prevent overwriting custom work done. It's not a ton of custom work, but it is a little bit. Hooks will never be overwritten.

Link to comment
Share on other sites

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