User profile email text field not showing address using user_email as ID

Support MB User Profile User profile email text field not showing address using user_email as IDResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16658
    NickNick
    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?

    #16673
    lighterdayzlighterdayz
    Participant

    I had that issue. See https://support.metabox.io/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
    NickNick
    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 TranAnh 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 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.