Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active August 29, 2015 14:03
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 jchristopher/6817e67604dd738bf47c to your computer and use it in GitHub Desktop.
Save jchristopher/6817e67604dd738bf47c to your computer and use it in GitHub Desktop.
Add a 'where will you be promoting ___' to AffiliateWP's registration form
<?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