Last active
July 15, 2016 15:17
-
-
Save mizrael/68368f510b82722d8028ee3efd01d67d to your computer and use it in GitHub Desktop.
Wordpress: how to handle redirects in shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class my_shortcode{ | |
public function __construct() | |
{ | |
add_shortcode('my_shortcode', array($this, 'render_form')); | |
add_action( 'template_redirect', array($this, 'handle_form_post') ); | |
} | |
function render_form(){ | |
// guess what goes there :D | |
} | |
function handle_form_post(){ | |
if ( isset( $_POST[''my_shortcode_form_name'] ) ) { | |
$dest_url = 'set your url'; | |
wp_redirect($dest_url); | |
exit; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment