Skip to content

Instantly share code, notes, and snippets.

@xnau
Created February 26, 2018 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/e9415170a97dc81931e9d64f67b0a444 to your computer and use it in GitHub Desktop.
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
<?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;
}
@xnau
Copy link
Author

xnau commented Feb 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment