I'm not much of a coder so I'm having a real hard time figuring this out.
I have a custom module and I'm trying to override user_account_form_validate() (from user.module) so that I can add a watchdog entry every time a specific instance of form_set_error() is called:
elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($form_state['values']['name']), 'LIKE')->range(0, 1)->execute()->fetchField()) {
form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name'])));
}
I need to do this because sometimes the Email registration module causes this error to fire and I want to make sure that this doesn't occur; so, to ensure users aren't seeing this error, I want to log it in watchdog if it occurs.
I know I can hack core and add the following line just after form_set_error:
watchdog('mymodule', 'Registration error: %name was already registered.', array('%name' => $form_state['values']['name']), WATCHDOG_ALERT);
But how I can I do this without hacking core? I tried various permutations of function
function mytheme_user_register_form_validate (&$form, &$form_state) {}
in a custom module but I couldn't successfully get Drupal to use my function instead of the core one.