I have two hooks in separate HTML request.
I have to pass some data i.e. variable from one to the other.
What is the most practical and transparent method for it?
I have two hooks in separate HTML request.
I have to pass some data i.e. variable from one to the other.
What is the most practical and transparent method for it?
It’s not possible to pass data from one HTTP request to another one on the fly. Once the script is finished, the data will be discarded.
What you can do is to store the data in a transient, and then retrieve it later. Here’s a simple example using set_transient()
:
set_transient( 'my_transient', $data, 1 * HOUR_IN_SECONDS );
Then, you can retrieve it using get_transient()
:
get_transient( 'my_transient' );