Last active
August 29, 2015 14:03
-
-
Save jchristopher/6817e67604dd738bf47c to your computer and use it in GitHub Desktop.
Add a 'where will you be promoting ___' to AffiliateWP's registration 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 | |
// add a 'where will you be promoting ___' to AffiliateWP's registration form | |
add_action( 'affwp_register_fields_before_tos', function() { | |
?> | |
<p> | |
<label for="affwp-user-where">Where will you be promoting SearchWP? USE SPECIFIC URLs (e.g. websites, social networks, etc.)</label> | |
<textarea id="affwp-user-where" name="affwp-user-where"></textarea> | |
</p> | |
<?php | |
}); | |
add_filter( 'affwp_registration_email', function( $message, $args ){ | |
if ( ! empty( $_POST['affwp-user-where'] ) ) { | |
$message .= "<br /><br />Where: " . esc_html( $_POST['affwp-user-where'] ); | |
} | |
$message = str_replace( "\n", '<br />', strip_tags( $message ) ); | |
return $message; | |
}, 10, 2 ); | |
add_action( 'affwp_process_register_form', function() { | |
if ( ! isset( $_POST['affwp-user-where'] ) || empty( trim( $_POST['affwp-user-where'] ) ) ) { | |
affiliate_wp()->register->add_error( 'where', 'You must indicate where you will be promoting SearchWP' ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment