Jump to content

action hooks - print_r ($vars); not working


Recommended Posts

Since I upgraded to v4 I can't print this array. Instead of displaying all the values in the array it only displays one number, which is the order number. Here is the code I have:

 

<?php
function create_store($vars) {
print_r ("<pre>");
print_r ($vars);
print_r ("</pre>");
}
add_hook("AfterShoppingCartCheckout",1,"create_store","");
?>

 

Is this a bug or am I doing something wrong?

Link to comment
Share on other sites

Its something your doing wrong. It has changed slightly from the old way.

If you look at the wiki at the bottom you will see the variables passed to each hook function.

eg...

<?php
function create_store($OrderID, $OrderNumber, $InvoiceID, $Products, $Addons, $Domains) {
echo"<pre>";
print_r($OrderID);
print_r($OrderNumber);
print_r($InvoiceID);
print_r($Products);
print_r($Addons);
print_r($Domains);
echo"</pre>";
}
add_hook("AfterShoppingCartCheckout",1,"create_store","");
?>

Link to comment
Share on other sites

  • 2 weeks later...

when using this, where does the oiutput display?

 

I know this may sound a stupid question, but I am trying to find out what is given in $params for the hook AfterModuleCreate and am using the below:

 

function actionhook_AfterModulecreate($vars) {
# This function runs when a module suspension command completes success
print_r($params);
}

 

Thing is it just doesnt seem to display anything..... do i need to get it to print somewhere, or have it email them?

Link to comment
Share on other sites

Ok,. realised I was using an old way as a method of using the hook, although I think I now am using it correctly, I still dont get any output (that i know of), using the below:

 

<?php 
function show_params_used($params) {
echo"<pre>";
print_r($params);
echo"</pre>";
}
add_hook("actionhook_AfterModuleSuspend",1,"show_params_used","");
?>

Link to comment
Share on other sites

I have put the following together, but for some reason simply uploading the file to the server stops the entire whmcs install working :shock::shock:

 

Surely my code isn't that bad??

 

Heres what I have -

<?php
# This function runs when a module create command completes success$

$outputFile = "moduleparams.txt";
$fh = fopen($outputFile, 'w') or die("can't open file"); 

add_hook("actionhook_AfterModuleSuspend",1,"show_params_used","");

function show_params_used($params) {
fwrite($fh, $params);
fclose($fh);
}
?>

Link to comment
Share on other sites

  • 3 months later...
  • 10 years later...

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