Created
March 1, 2016 11:15
Revisions
-
mahbubme created this gist
Mar 1, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ // remove the filter remove_filter( 'woocommerce_process_registration_errors', 'dokan_seller_registration_errors' ); remove_filter( 'registration_errors', 'dokan_seller_registration_errors' ); // New registration form erros handling function dokan_update_seller_registration_errors( $error ) { $allowed_roles = apply_filters( 'dokan_register_user_role', array( 'customer', 'seller' ) ); // is the role name allowed or user is trying to manipulate? if ( isset( $_POST['role'] ) && !in_array( $_POST['role'], $allowed_roles ) ) { return new WP_Error( 'role-error', __( 'Cheating, eh?', 'dokan' ) ); } $role = $_POST['role']; if ( $role == 'seller' ) { $phone = trim( $_POST['phone'] ); if ( empty( $phone ) ) { return new WP_Error( 'phone-error', __( 'Please enter your phone number.', 'dokan' ) ); } } return $error; } add_filter( 'woocommerce_process_registration_errors', 'dokan_update_seller_registration_errors' ); add_filter( 'registration_errors', 'dokan_update_seller_registration_errors' );