Link to home
Create AccountLog in
Avatar of steva
steva

asked on

Defining functions in the WordPress functions.php file

I  tried to define a function in my functions.php file as below:

function here ($place) { // dbgsa
	$debug = get_post_meta( $order_id, 'debug', true );
     $debug .= $place';
	update_post_meta($order_id, 'debug', $debug);
}

Open in new window


The plan was then to call this from inside various action hook functions to have a record of how control passed through the code. So there might be something like:

User generated image
Then if G was in the string I knew I went through that point in the code.   But this doesn't work.  here() doesn't appear to get entered.  Does anyone see the problem?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of steva
steva

ASKER

Yes!  Of course. $order_id needs to be passed in, and then it works.   My bad.  I thought I was fighting some corner case of the WordPress functions.php file and overlooked the simple.

BTW, I don't think "die('Made it here!');". would work because the page doesn't get displayed. That's why I can't just  echo debug comments.

And you would want to put here()  somewhere that is not inside any conditional control structure.  Actually, no. The whole point is to see if control made it through those conditional structures.

Thanks for your help.  I split the points.