Jump to content

Problem making a hook for a registrar module. Help please!!!


mhramos

Recommended Posts

Hello,

 

We are trying to make a customization for a registrar module (by hooks). We need the module to work exactly as it does any registrar official WHMCS module but with the following customizations:

 

 

  • If the country used in the customer's personal data is Cuba. Then the data to be used at the time of registering / transferring the domain is the company data used for the administrative and billing contact (those selected in the domain tab of the general configuration of WHMCS) or other saved in the hooks file. In other words, if the client is from Cuba, then the domains for this client are registered in favor of our company and not in favor of the client.

 

 

  • If the client is from Cuba, then he does not have the possibility to modify the WHOIS data of the domain from his client area.

 

 

  • For customers from other countries the module should function exactly like the official module.

 

 

 

 

 

According to WHMCS this can be done by Hooks. Bellow the WHMCS suggestion:

 

We have made a number of additions to WHMCS which would potentially facilitate this customisation to be made without the need to change the eNom module source code. This has the added benefit of making updates easier for you to apply as well.

 

For example, the querying or saving of domain whois details could be aborted if the country value in the array of parameters equalled Cuba:

* http://developers.whmcs.com/hooks-re...contactdetails

* http://developers.whmcs.com/hooks-re...contactdetails

And the whois contact details which are submitted to the registrar could potentially be changed using the PreRegistrarGetContactDetails action hook point.

 

We already made the hook file as suggested but I think the module is not recognizing the hook. It does not generate errors, absolutely nothing, as if it were not. I have already disabled the module and I have reactivated it and nothing happens. I'm testing it with the Email registrar module and ENOM test enviroment. Any idea why the hook is not recognized?

 

The file hooks.php is on registrar root folder as suggested: /home/useraccount/public_html/modules/registrars/enom/hooks.php

 

The domain registration process is performed as usual and the hook's indications of changing the data are not taken into account if the customer's country is Cuba. Here is the code written in the hooks.php file.

 

<?php

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

function fix_cu_contact($vars)
{

$CC = $vars['countrycode'];

global $params;
   //if ($CC == 'CU') { #Commenting to temporaly change all WHOIS data before register any domain (test pourposes)

       $params['address1'] = $vars['adminaddress1'];
       $params['address2'] = $vars['adminaddress2'];
       $params['city'] = $vars['admincity'];
       $params['state'] = $vars['adminstate'];
       $params['fullstate'] = $vars['adminfullstate'];
       $params['countrycode'] = 'US';
       $params['countryname'] = 'United States';
       $params['phonenumber'] = $vars['adminphonenumber'];
       $params['phonecc'] = '+1';
       $params['fullphonenumber'] = $vars['adminfullphonenumber'];


  // }
}
add_hook("PreRegistrarRegisterDomain", 1, "fix_cu_contact");

?>

 

 

Can anyone give me a hint as to why it is not working?

Edited by mhramos
code change
Link to comment
Share on other sites

I am already put the file in includes/hooks/fix_cu_contact.php calling the hook point "PreRegistrarRegisterDomain".

 

According to

 

https://developers.whmcs.com/domain-registrars/module-parameters/

https://developers.whmcs.com/hooks-reference/domain/#preregistrarregisterdomain

 

This hook should modify the WHOIS information that is passed to the registrar at the time of registering a domain. However, it still does not work. Please, help me, I need to know why the hook does not modify WHOIS data. I can not find any errors in the logs, I'm blind.

 

Greetings

Link to comment
Share on other sites

Sorry my english... i speak spanish.

 

Until finally, the parameters are taken by the function ... here is the updated code.

 

<?php

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

function fix_cu_contact($vars)
{

$CC = $vars['params']['countrycode'];


   //if ($CC == 'CU') { #Commenting to temporaly change all WHOIS data before register any domain (test pourposes)
       mail("xxxx@xxxx.xxxxxxxxx", $vars['params']['countrycode'], "Linea 0\nLinea 2\nLinea 3"); // (test pourposes too)
       $vars['params']['address1'] = $vars['params']['adminaddress1'];
       $vars['params']['address2'] = $vars['params']['adminaddress2'];
       $vars['params']['city'] = $vars['params']['admincity'];
       $vars['params']['state'] = $vars['params']['adminstate'];
       $vars['params']['fullstate'] = $vars['params']['adminfullstate'];
       $vars['params']['countrycode'] = 'US';
       $vars['params']['countryname'] = 'United States';
       $vars['params']['phonenumber'] = $vars['params']['adminphonenumber'];
       $vars['params']['phonecc'] = '+1';
       $vars['params']['fullphonenumber'] = $vars['params']['adminfullphonenumber'];
mail("xxxx@xxxx.xxxxxxxxx", $vars['params']['countrycode'], "Linea 1\nLinea 2\nLinea 3"); // (test pourposes too)


  // }
}
add_hook("PreRegistrarRegisterDomain", 1, "fix_cu_contact");

?>

 

 

 

 

Look what I put to send me an email (for testing purposes) before the variables are processed ... and another one after processed ... and correct !! I get the first email with the original country ... and the second email already with the country changed to the United States ... I commented the IF so that it applies at the moment to everything.

As well as it is internally within the function it obtains well the variables that are sent to it by WHMCS and makes the change ... the question is now ... How to return them to change WHOIS? According to the hookpoint I used now (PreRegistrarRegisterDomain) ... look at the documentation and above all the sample code: https://developers.whmcs.com/hooks-reference/domain/#preregistrarregisterdomain

 

Documentaation about "PreRegistrarRegisterDomain" says that an array can be returned .. and if we return the same overwritten array? (Sorry if I'm saying a dumb) Because the thing is that inside the function makes the change well already ... but it does not leave the function ... to the registrar the client's data are still being sent.

 

PS: the hook is in /includes/hooks folder.

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.

×
×
  • 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