hi Luo, thanks for the assistance... its not quite behaving, here is where we are at:
Ive modified your code as it didn't render the short-code data for some reason and a slightly modified version didn't include the inverted commas around the values, but this does (below):
However, something is not quite right.
function get_post_var_saved($atts, $content){
$atts = shortcode_atts( array(
'slug' => 'generic-industry-taxonomy',
), $atts);
//$res = '';
if(isset($_POST[$atts['slug']])){
$res = implode('","', $_POST[$atts['slug']]);
}
return '"'.$res.'"';
}
add_shortcode('get_post_var', 'get_post_var_saved');
This is the short-code: [get_post_var]
It outputs fine and in the correct format from what I can see:
---> direct output: "wireless","wine-spirits"
However, when I use the short-code and click submit if there is more than one selected the field disappears - see image.
One option selected: hidden link
Multiple selected: hidden link
[cred_generic_field type='multiselect' field='generic-industry-taxonomy' class='ind-taxonomy']
{
"required":1,
"persist":1,
"default":[[get_post_var]],
"options":[[wpv-view name="partner-industries-select"]]
}
Image from CRED editor: hidden link
If I used the short-code output directly in the default field (just to check on the output formatting, then check on the front end it renders the values as expected.
See image: hidden link
So must there be something else in the short-code output that is breaking it? I can see where... and I have been playing around for ages trying to figure it out..
The default values filled with the shortcode output below:
[cred_generic_field type='multiselect' field='generic-industry-taxonomy' class='ind-taxonomy']
{
"required":1,
"persist":1,
"default":["wireless","wine-spirits"],
"options":[[wpv-view name="partner-industries-select"]]
}
thanks for the help