Jump to content

Strange hooks behaviour


lunaticnoise

Recommended Posts

Hello,

 

I have a file /includes/hooks/hooks.php with the following code:

 

<?php

add_hook('ClientAreaPage', 1, function($vars) {
   var_dump("ClientAreaPage");
});

add_hook('AdminAreaPage', 1, function($vars) {
   var_dump("AdminAreaPage");
});

add_hook('PreRegistrarGetDNS', 1, function($vars) {
   var_dump("PreRegistrarGetDNS");
});

add_hook('AfterRegistrarGetDNS', 1, function($vars) {
   var_dump("AfterRegistrarGetDNS");
});

add_hook('PreRegistrarSaveNameservers', 1, function($vars) {
   var_dump("PreRegistrarSaveNameservers");
});

add_hook('AfterRegistrarSaveNameservers', 1, function($vars) {
   var_dump("AfterRegistrarSaveNameservers");
});

add_hook('AfterRegistrarGetContactDetails', 1, function($vars) {
   var_dump("AfterRegistrarGetContactDetails");
});

add_hook('PreRegistrarGetContactDetails', 1, function($vars) {
   var_dump("PreRegistrarGetContactDetails");
});

 

I am trying to execute some of the above hooks, but only ClientAreaPage and AdminAreaPage are called when I visit any page of clientside or adminside.

 

I know that PreRegistrarGetDNS, AfterRegistrarGetDNS, PreRegistrarSaveNameservers, AfterRegistrarSaveNameservers, AfterRegistrarGetContactDetails and PreRegistrarGetContactDetails are only called in few actions, for example when the domain register is getting the nameservers, contact details or saving dns records so I go to any admin domain page to force these hooks but sadly they are never called.

 

I also have few breakpoint in the code but the debuger only stops at ClientAreaPage and AdminAreaPage hooks.

 

Is anyone having this issue? My WHMCS version is 7.1.1

Edited by lunaticnoise
Php code within tags to better reading
Link to comment
Share on other sites

Maybe I did not explain proper the problem. var_dump is only a php sentence to stop the debuger (xdebug), you can forget about the result of the var_dump() function.

 

The only hooks executed in my installation are ClientAreaPage and AdminAreaPage, the rest in the first post are never executed. I can assure that, because I have IDE breakpoints in all of them and the process never stops there, it only stops at ClientAreaPage and AdminAreaPage.

 

It is very extrange behaviour, isn't it?

 

senq thanks for your time and responses!

Link to comment
Share on other sites

try to debug it using this code:

 

<?php 

add_hook('ClientAreaPage', 1, function($vars) { 
   var_dump("ClientAreaPage"); 
}); 

add_hook('AdminAreaPage', 1, function($vars) { 
   var_dump("AdminAreaPage"); 
}); 

add_hook('PreRegistrarGetDNS', 1, function($vars) { 
   logActivity("Debug: PreRegistrarGetDNS"); 
}); 

add_hook('AfterRegistrarGetDNS', 1, function($vars) { 
   logActivity("Debug: AfterRegistrarGetDNS"); 
}); 

add_hook('PreRegistrarSaveNameservers', 1, function($vars) { 
   logActivity("Debug: PreRegistrarSaveNameservers"); 
}); 

add_hook('AfterRegistrarSaveNameservers', 1, function($vars) { 
   logActivity("Debug: AfterRegistrarSaveNameservers"); 
}); 

add_hook('AfterRegistrarGetContactDetails', 1, function($vars) { 
   logActivity("Debug: AfterRegistrarGetContactDetails"); 
}); 

add_hook('PreRegistrarGetContactDetails', 1, function($vars) { 
   logActivity("Debug: PreRegistrarGetContactDetails"); 
});

 

run few tests, then go to Utilities -> Logs -> Activity Logs, and check if there is any records in there started with "Debug: "

Link to comment
Share on other sites

I have change a little bit the code, to show you how only the ClientAreaPage and AdminAreaPage hoos run.

 

 

add_hook('ClientAreaPage', 1, function($vars) {
   logActivity("Debug: ClientAreaPage");
});

add_hook('AdminAreaPage', 1, function($vars) {
   logActivity("Debug: AdminAreaPage");
});

add_hook('PreRegistrarGetDNS', 1, function($vars) {
   logActivity("Debug: PreRegistrarGetDNS");
});

add_hook('AfterRegistrarGetDNS', 1, function($vars) {
   logActivity("Debug: AfterRegistrarGetDNS");
});

add_hook('PreRegistrarSaveNameservers', 1, function($vars) {
   logActivity("Debug: PreRegistrarSaveNameservers");
});

add_hook('AfterRegistrarSaveNameservers', 1, function($vars) {
   logActivity("Debug: AfterRegistrarSaveNameservers");
});

add_hook('AfterRegistrarGetContactDetails', 1, function($vars) {
   logActivity("Debug: AfterRegistrarGetContactDetails");
});

add_hook('PreRegistrarGetContactDetails', 1, function($vars) {
   logActivity("Debug: PreRegistrarGetContactDetails");
});

 

 

I have made some test, getting the domain contacts and one change on nameservers and please see the attached

Captura de pantalla 2017-02-28 a las 22.05.03.png

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