I'm developing a plugin. At present I have two files. dotmailer.php and dotmailer-add.php. I'm creating a newsletter widget.
dotmailer.php plugin adds an admin menu, with options. It allows the admin to store an email address which is used as authentication for the API I'm using. This is taken from the options page form and stored as such:
$apiemail = get_option('apiemail');
I've also created a widget, this is the front-facing bit. The user inputs their email in the form and the form POSTs to a new file called dotmailer-add.php. So this file has the variable
$useremail taken from the form.
Now I'm stuck, because I need the var
$useremail to be useable witin dotmailer-add.php. There is no way to send this through a form or anything because the form already posts through to the wordpress options.php file.
I know when working with PHP sessions are often used to store variables that are needed across multiple files. My issue is that the admin will not be submitting the API emal to the Wordpress options page every time they log in, so they won't be starting a new session each time. I need the var
$useremail to be available across all my plugin files at all times.
I tried using
include but unfortunately I get whitescreened with no errors (error messages are on).
How can I set a global variable through Wordpress options and have it available across multiple files within a plugin?