Last active
September 18, 2019 19:26
-
-
Save robertmorel-uk/b2d7558dea8d182b4df4fce5451abf00 to your computer and use it in GitHub Desktop.
PHP - wp-testing addon
This file contains hidden or 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
//https://mailme.dev.cc/?x=1&a=1&b=2&c=3&d=4 | |
add_action ('wp_loaded', 'my_custom_redirect'); | |
function my_custom_redirect() { | |
if(!empty($_GET['x'])){ | |
//set variables from get | |
$a = sanitize_text_field( $_GET['a'] ); | |
$b = sanitize_text_field( $_GET['b'] ); | |
$c = sanitize_text_field( $_GET['c'] ); | |
$d = sanitize_text_field( $_GET['d'] ); | |
//send results to admin | |
$redirect = site_url().'/privacy-policy?a='.$a.'&?b='.$b.'&?c='.$c.'&?d='.$d; | |
$to = '[email protected]'; | |
$subject = 'New submission from form'; | |
$headers = array( | |
'From: <[email protected]>' . "\r\n", | |
'Cc: [email protected]' . "\r\n", | |
"MIME-Version: 1.0" . "\r\n", | |
"Content-type:text/html;charset=UTF-8" . "\r\n", | |
); | |
$message = 'form data: '.$redirect; | |
wp_mail( $to, $subject, $message ); | |
wp_redirect($redirect); | |
exit; | |
} | |
//The results page | |
if(!empty($_GET['y'])){ | |
//set variables from get | |
$a = sanitize_text_field( $_GET['a'] ); | |
$b = sanitize_text_field( $_GET['b'] ); | |
$c = sanitize_text_field( $_GET['c'] ); | |
$d = sanitize_text_field( $_GET['d'] ); | |
//send results to admin | |
$redirect = site_url().'/privacy-policy?a='.$a.'&?b='.$b.'&?c='.$c.'&?d='.$d; | |
$to = '[email protected]'; | |
$subject = 'Your results'; | |
$headers = array( | |
'From: <[email protected]>' . "\r\n", | |
'Cc: [email protected]' . "\r\n", | |
"MIME-Version: 1.0" . "\r\n", | |
"Content-type:text/html;charset=UTF-8" . "\r\n", | |
); | |
$message = 'view your results: '.$redirect; | |
wp_mail( $to, $subject, $message ); | |
} | |
} | |
/* | |
user completes form and redirected to results page with x param | |
email input box | |
post to self and append y | |
echo message to confirm | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment