I want to remove email field from woocommerce edit account page to prevent user from changing his email address.
it is so easy to remove the front-end part by editing myaccount/form-edit-account.php template. But it's just from the form.
I want to remove if from backend too, so no one can put text box with email name to the form and change the email.
the backend function which does the edit process is here
https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-form-handler.php#L141
as you can see, there is no filter or action to exclude email from processing.
any help would be appreciated.
Solution (thanks to @Reigel)
As I said, I had removed the email field from the template file but a malicious user could inject an input field with account_email and change the email. What I wanted was to ignore the POSTED email, if there was any.
so using woocommerce_save_account_details_errors
action, it's possible to do it
class example
add_action( 'woocommerce_save_account_details_errors', array( $this, 'remove_email_from_edit_account_process' ), 10,
2 );
public function remove_email_from_edit_account_process( $errors, $user ) {
if ( ! empty( $user->user_email ) ) {
unset($user->user_email);
}
}