Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Banilla87

    (@banilla87)

    Probably user_profile_update_errors not work with wordpress core?

    Thread Starter Banilla87

    (@banilla87)

    Thanks but the field is always saved and no error is returned!
    I show you that code just for example. My original one is:

    // ADD FIELD
    function add_additional_user_meta( $profileuser ) {
    
       // here my input fields
       <input type="text" size="20" name="user_pec" id="user_pec" value="<?php echo esc_attr( $profileuser->user_pec ); ?>" />
    
    }
    add_action('show_user_profile', 'add_additional_user_meta');
    add_action('edit_user_profile', 'add_additional_user_meta');
    
    // SAVE FIELD
    function save_additional_user_meta( $user_id ) {
       // here I save fields
       update_user_meta( $user_id, 'user_pec', sanitize_text_field( $_POST['user_pec'] ) );
    }
    add_action( 'personal_options_update', 'save_additional_user_meta' );
    add_action( 'edit_user_profile_update', 'save_additional_user_meta' );
    
    // CHECK FIELD
    function check_fields($errors, $update, $user){
       // here make some validation
        if ( ! isset( $_POST['user_pec'] ) ) {
            $errors->add( 'empty_user_pec', __( '<strong>ERROR</strong>: Insert e-mail PEC.' ), array( 'form-field' => 'user_pec' ) );
        } elseif ( !is_email( $_POST['user_pec'] ) ) {
            $errors->add( 'invalid_user_pec', __( '<strong>ERROR</strong>: not valid e-mail PEC' ), array( 'form-field' => 'user_pec' ) );
        } elseif ( ( $owner_id = email_exists($_POST['user_pec']) ) && ( !$update || ( $owner_id != $user->ID ) ) ) {
            $errors->add( 'user_pec_exists', __('<strong>ERROR</strong>: Already exist'), array( 'form-field' => 'user_pec' ) );
        }
       }
    }
    add_filter('user_profile_update_errors', 'check_fields', 10, 3);

    Last function seems not work!
    If I put a number inside the field, error appears but the field is saved however!

    Any idea?

    Thread Starter Banilla87

    (@banilla87)

    Please Help me!

    Hi everybody!
    I’m trying to do the same thing but it’s not easy.

    I created a custom taxonomy “author” associated with woocommerce product custom post type and it work!

    So if I click on a taxonomy term (es. “mister-x”) I can view all the product of mistex-x.

    But I would like to add a photo and description of that author before the loop of posts..

    What I can do?

    Many Thanks

    Hi! I’m interested too with this option.. is it possible?

Viewing 5 replies - 1 through 5 (of 5 total)