Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Add NIP $ REGON to register*/
- add_action( 'woocommerce_register_form', 'crf_registration_form' );
- function crf_registration_form() {
- $NIP = ! empty( $_POST['NIP'] ) ? intval( $_POST['NIP'] ) : '';
- $REGON = ! empty( $_POST['REGON'] ) ? intval( $_POST['REGON'] ) : '';
- ?>
- <p>
- <label for="NIP"><?php esc_html_e( 'NIP*', 'crf' ) ?><br/>
- <input type="number"
- id="NIP"
- name="NIP"
- value="<?php echo esc_attr( $NIP ); ?>"
- class="input"
- />
- </label>
- <label for="REGON"><?php esc_html_e( 'REGON*', 'crf' ) ?><br/>
- <input type="number"
- id="REGON"
- name="REGON"
- value="<?php echo esc_attr( $REGON ); ?>"
- class="input"
- />
- </label>
- </p>
- <?php
- }
- /*Errors*/
- add_filter( 'registration_errors', 'crf_registration_errors', 10, 3 );
- function crf_registration_errors( $errors, $sanitized_user_login, $user_email ) {
- if ( empty( $_POST['NIP'] ) ) {
- $errors->add( 'NIP_error', __( '<strong>Błąd</strong>: Proszę wpisać numer NIP', 'crf' ) );
- }
- if ( empty( $_POST['REGON'] ) ) {
- $errors->add( 'REGON_error', __( '<strong>Błąd</strong>: Proszę wpisać numer REGON', 'crf' ) );
- }
- return $errors;
- }
- /*Save NIP & REGON*/
- add_action( 'user_register', 'crf_user_register' );
- function crf_user_register( $user_id ) {
- if ( ! empty( $_POST['NIP'] ) ) {
- update_user_meta( $user_id, 'NIP', intval( $_POST['NIP'] ) );
- }
- if ( ! empty( $_POST['REGON'] ) ) {
- update_user_meta( $user_id, 'REGON', intval( $_POST['REGON'] ) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement