Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillBrubaker/57157ee587a9d580ddef to your computer and use it in GitHub Desktop.
Save WillBrubaker/57157ee587a9d580ddef to your computer and use it in GitHub Desktop.
An example of how to redirect after survey submission for the Awesome Surveys WordPress plugin. Requires Awesome Surveys version > 1.1.1
<?php
/*
Plugin Name: Custom Redirect for Awesome Surveys
Plugin URI: http://www.willthewebmechanic.com/awesome-surveys
Description: Redirects to a specified link after survey submission
Version: 1.0
Author: Will Brubaker
Author URI: http://www.willthewebmechanic.com
License: GPLv3.0
*/
add_filter( 'after_awesome_survey_response_processed', 'wwm_after_survey_redirect', 10, 2 );
/**
* Filters the URL
* @param string $url the url that is being filtered
* @param array $args an array of arguments. At the time of creation this array contained
* 'survey_id' which is, well, the id of the survey being processed
* 'survey' which is the survey that was responded to and 'responses' which
* is a copy of the 'questions' array that was posted i.e. $_POST['question']. Use these values to decide
* where to redirect to or return null if not re-directing.
* @return string the filtered url
* @since 1.0
* @author Will the Web Mechanic <will@willthewebmechanic.com>
*/
function wwm_after_survey_redirect( $url = null, $args = array() )
{
$url = 'http://www.willthewebmechanic.com';
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment