Pseudo code wise something along the lines of the below. This is only only pseudo code though meant to show the general concept.
PHP Code:
/**
* @implement hook_form_FROM_ID_alter
*/
mymodule_form_user_register_alter(&form,&form_state) {
/**
* Add your checkbox
*/
$form['mycheckbox'] = array(
'#type'=> 'checkbox',
'#title'=> 'The Title'
);
/**
* Add custom submit handler
*/
$form['#submit'][] = 'mymodule_user_register_submit';
}
/**
* Custom submit handler for user registration form.
*/
function mymodule_user_register_submit(&$form,&$form_state) {
if(isset($form_state['values']['mycheckbox']) && !empty($form_state['values']['mycheckbox'])) {
// send the email
}
}
In short use hook_form_FROM_ID_alter to modify the structure of the default user registration form. Most importantly add a custom submit routine so that when the form is submitted without validation errors the email can be sent without modifying core code. Most likely much to it with all the details filled in but that is the gist of it.
Bookmarks