Created
February 26, 2018 20:06
-
-
Save xnau/e9415170a97dc81931e9d64f67b0a444 to your computer and use it in GitHub Desktop.
Demonstrates how to enact a conditional redirect based on the submitted data from a Participants Database signup form
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
<?php | |
// place the filter on the posted data before it is submitted | |
add_filter( 'pdb-before_submit_signup', 'xnau_conditional_signup_redirect' ); | |
/** | |
* changes the signup form "thanks" page depending on a value in the form | |
* | |
* @param array $post the posted data | |
* @return array post data | |
*/ | |
function xnau_conditional_signup_redirect( $post ) | |
{ | |
switch( $post['signup_type'] ) { // the "signup_type" value tells us which thanks page to use | |
case 'volunteer': | |
$thankspage = 'volunteer-thanks'; | |
break; | |
case 'contributor': | |
default: | |
$thankspage = 'contributor-thanks'; | |
break; | |
} | |
$post['thanks_page'] = Participants_Db::find_permalink( $thankspage ); | |
// now return the altered post data | |
$return $post; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The signup thanks message will be the same in both cases, so you can either blank it out and just have the page content show, or you can use the 'pdb-before_signup_thanks' filter to set up your dynamic thank you message.