form redirection with parameter
Hello,
is there a way to pass a parameter to the page I want to redirect to?
I've configured the page in settings - go to page. I need to pass a parameter like this /mypage/?name=#name#
I'd like to do that like in mail notification with the tags #name# or #id# etc.
I'm new and I don't know if it can be done.
Thank you
Chiara
1 Answers
Hello Chiara,
I had the same need on another project, so I share my code with you :
Add this to a custom plugin of your own or in function.php file
function URLParam( $atts ) {
extract( shortcode_atts( array(
'param' => 'param',
), $atts ) );
//two different values for action parameter :
if($_GET[$param]==='ok'){
return '<span style="border:1px solid #00FE00 ;padding:0 5px;background-color:#E5FEE5;">Merci pour votre confiance</span><br/><br/>';
}else if ($_GET[$param]==='cancel'){
return '<span style="color:red;border:1px solid red;padding:0 5px;background-color:#F9D8D8;">Votre transaction a été <b>annulée</b></span><br/><br/>';
}else{
return; //return 'Cas non traité : '. $_GET[$param];
}
}
add_shortcode('URLParam', 'URLParam');
Then edit the destination page within Wordpress editor and add this :
[URLParam param='action']
Now you can redirect to this page with some action parameter, like : paypal/?action=ok
In the above case a nice green message should be displayed "Merci pour votre confiance" (Thank you for you trust)
Edit the above code to your needs.
Hope this helps.
I had the same need on another project, so I share my code with you :
Add this to a custom plugin of your own or in function.php file
function URLParam( $atts ) {
extract( shortcode_atts( array(
'param' => 'param',
), $atts ) );
//two different values for action parameter :
if($_GET[$param]==='ok'){
return '<span style="border:1px solid #00FE00 ;padding:0 5px;background-color:#E5FEE5;">Merci pour votre confiance</span><br/><br/>';
}else if ($_GET[$param]==='cancel'){
return '<span style="color:red;border:1px solid red;padding:0 5px;background-color:#F9D8D8;">Votre transaction a été <b>annulée</b></span><br/><br/>';
}else{
return; //return 'Cas non traité : '. $_GET[$param];
}
}
add_shortcode('URLParam', 'URLParam');
Then edit the destination page within Wordpress editor and add this :
[URLParam param='action']
Now you can redirect to this page with some action parameter, like : paypal/?action=ok
In the above case a nice green message should be displayed "Merci pour votre confiance" (Thank you for you trust)
Edit the above code to your needs.
Hope this helps.
Please login or Register to submit your answer