I have a Formidable Form View which uses the key in the URL to filter the view.
?resultskey=[key sanitize_url=1]
I want to create a shortcode which pulls values from the specific entry key.
Is it possible to use the values from the key (as set in the URL) in a php file?
Sure. You can do this:
$entry_id = FrmEntry::get_id_by_key($entry_key);
$entry = FrmEntry::getOne( $entry_id );
and then "$entry" will contain all the information
Thanks @Rob LeVine
I tried the following in a shortcode but all I got was "There has been a critical error on this website."
$entry_id = FrmEntry::get_id_by_key($entry_key)
$entry = FrmEntry::getOne( $entry_id );
echo $entry;
Turn on your error display (or look in your log file) to see what the full error is. That code is fine as is, though you have to set $entry_key at some point. Generally that means some sort of syntax error. Also, you'll want to do print_r($entry) or since it's an array of info.
Thanks @Rob LeVine
I got
PHP Parse error: syntax error, unexpected '$entry' (T_VARIABLE)
How do I 'set' $entry_key ?
Would it not be taken from the parameter in the ULR resultskey?
Ha! The error is because of the missing semicolon (;) at the end of the first line. I edited my previous response.
The value that you put into #entry_key can come from the URL via the $_REQUEST global variable or it can be passed in via the shortcode invocation, whichever works better for you.
Please login or Register to submit your answer