Custom Fields
Re-Envisioned
Support MB User Profile User profile email text field not showing address using user_email as ID

  • Creator
    Topic
  • #16658
    Resolved Nick
    Participant

    I have a field group attached to a front end form that is supposed to pull user info. One field is a text field that’s supposed to show the user email address. I’ve tried user_email, email, and user_login (registration sets login to email) as the field ID and none of them appear to be pulling anything. User email is stored in the _users table but is not a field in the _usermeta table. What am I doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #16673
    lighterdayz
    Participant

    I had that issue. See https://metabox.io/support/topic/prompt-to-change-password-shows-on-edit-form/

    It shows the filter for showing the email (below). Then add the ID.

    add_filter( 'rwmb_profile_info_fields', function( $fields ) {
        $fields['email'] = [
            'name' => 'Email',
            'id'   => 'user_email',
            'type' => 'email',
        ];
        return $fields;
    } );
    #18461
    Nick
    Participant

    I’m finally just now getting back to this project. I added that code into my functions.php (not sure if that’s the right place), then have an email field with ID user_email, but it’s still not pulling the email address. Any suggestions?

    #18471
    Anh Tran
    Keymaster

    Hi Nick, you probably need to use a filter to change the value displayed:

    add_filter( 'rwmb_user_email_field_meta', function( $meta, $field, $saved ) {
        $user = wp_get_current_user();
        return $user->user_email;
    }, 10, 3 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.