Reputation: 3314
I'm trying to pass or store a file path string which the CMS user provides in the shortcode, and use this in a function which is then executed when the short code has rendered.
Here are the details:
function wpsdc( $atts ) {
extract( shortcode_atts( array(
'file_path' => '',
'text' => ''
), $atts ) );
$wpsdc_output = wpsdc_short_code($text);
return $wpsdc_output;
}
add_shortcode('wpsdc','wpsdc');
My wpsdc_short_code function returns some basic form html:
<form action='wpsdc-validate-email.php' method='post' id='download_content'>
<input id='emailtext' name='email' type='text'>
<button id='submit-email' type='submit'>Click</button>
</form>
What I am aiming to do is return a string (which I render as an anchor text link) to the file path defined in the initial short code.
[wpsdc file_path='/downloads/some_pdf_file.pdf' text='Click']
How therefore do I get the $file_path variable to my 'wpsdc-validate-email.php' file WITHOUT having the file string visible in the html form mark-up?
Thank you very much in advance.
Upvotes: 0
Views: 995
Reputation: 11852
I can see a few approaches to this:
Use php's mcrypt
functions to encrypt your file_path
and store it in a hidden field on the form, then use mcrypt_decrypt
to decode it in your form action script. Documentation here: http://www.php.net/manual/en/book.mcrypt.php
Store the file_path
in a php $_SESSION
and use this. See this Wordpress support thread for the basics: http://wordpress.org/support/topic/using-session-in-wordpress
You could also use a plugin like WP Session Manager in the event that your PHP server is locked down.
Upvotes: 1