Okay, I'm still missing something basic. I'll admit it's probably PHP rather than WordPress, but here's my situation.
functions.php:
global $testvar;
add_action( 'hook_defined_in_plugin1', 'my_process_plugin1_data');
I've written "plugin2.php" and installed/activated it. Its code contains
global $testvar;
function my_process_plugin1_data( --args as from plugin1-- )
{
global $testvar;
$testvar="this is in the data processing function";
}
Finally in a PHP template file for a page displayed after my_process_plugin1_data executes, I have
global $testvar;
echo "<br />Confirm var value===".$testvar."===</br>";
but $testvar shows up as an empty string.
I've confirmed the hook/action works -- in the template file I can retrieve a cookie that's set by the my_process_plugin1_data function. But I just can't seem to get the function and the page communicating through a variable.
I've searched the docs and the book "WordPress Plugin Development" -- but nothing jumps out as the step-by-step way to set up this communication.