WP Plugin sharing session data between action|filter hook functions
-
A plugin which provides access to multiple add_action and or add_filter hooks … all php hook code is located in one php file
Expectation was that this file would be loaded once by the plugin for any given user connection/session … this sadly is not the case … sharing data between the various hook functions has become overly complicated
The intent was that a class of vars would use the __construct to init a set of vars once then each filter/action function could either reset and or use those vars as needed
the Hook file used the following code
`if (! defined SessionVars) {
define (SessionVars);
$snVars = new snVars();
}`
which fails to provide the desired effect due to the plugin calling this file multiple times and with each call resets the snVarsGiven the plugin uses WP’s Post ID to identify the current session what can be done to share data between these hook functions?
Do I need to make a custom table and store/retrieve these vars by PID?
-
I don’t see any WordPress.com sites under your account here.
What is the URL of the site with the problem?
-
I am not a WordPress Developer … retired JoAT maintaining a WordPress site for a not for profit society on my own dime
This problem isn’t visible … unique URLs are emailed to members … no other way has been made available to navigate to these forms online
Using a WP Form Builder Plugin that provides function hooks with; Form Filters (intended for language translations), and Form Actions (like before email)
URL params are being passed in to the Form Filters to automatically fill in some Form Fields … the before email action then builds XML and MD5 file attachments for the submitted email
The missing data is due to the PLUGIN loading the hooks file more than once … meaning … the data I was expecting to be available (shared) between each Hook Function in the hook file is actually lost because the variables are reinitialized each time the file is opened (variables loose scope when the file is closed)
I am looking for a way to ensure this shared data is maintained while the session is active (POST_ID defines a session) … shared data must only be scoped to the session … hopefully there is a way to do this without having to resort to using an SQL table record (not impossible just seemingly overkill)
-
I did not see you mention it here, but what is the URL of the site with the problem?
We do not offer WP Form Builder on WordPress.com, so it sounds like you may be using a self-hosted websites, which are sites that you create on a “traditional web host” like Bluehost, GoDaddy, etc.
Is that the case, that you are hosting with another provider?
-
Is where I host this WP Page an issue … I thought this was a WP support forum … I am just looking for some direction on how to get past what I consider a DATA SCOPE ISSUE … if this is the wrong place the sorry for the noise
-
Hi there!
These forums are for WordPress.com hosted sites only. If your site is using the open-source WordPress.org software, we won’t be able to help you out and you’ll want to seek help at these forums:
https://wordpress.org/support/forums/
- The topic ‘WP Plugin sharing session data between action|filter hook functions’ is closed to new replies.