Email not saving in backend

Support MB Frontend Submission Email not saving in backendResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #35380
    YasmineYasmine
    Participant

    Hello - I have a user form, and when you log in, the user can see that their email is already filled in their frontend user profile form. However, the email is not saving in the backend user form. When you revisit the user form on the front end, the value still shows. But I do not understand why this then does not save in the backend - everything else saves in the backend perfectly! Please help!

    #35385
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please share the code that creates custom fields and the shortcode on your site? Some screenshots would be better to troubleshoot the issue.

    #35404
    YasmineYasmine
    Participant

    Here is the code:

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'  => __( 'Profile', 'your-text-domain' ),
            'id'     => 'academic_profile',
            'type'   => 'user',
            'tabs'   => [
                'basic_info_tab'   => [
                    'label' => 'Basic Info',
                    'icon'  => 'dashicons-admin-users',
                ],
                'academic_profile' => [
                    'label' => 'Academic Profile',
                    'icon'  => 'dashicons-welcome-learn-more',
                ],
                'social_sharing'   => [
                    'label' => 'Social Sharing',
                    'icon'  => 'dashicons-share1',
                ],
            ],
            'fields' => [
                [
                    'name'    => __( 'Academic Title', 'your-text-domain' ),
                    'id'      => $prefix . 'academic_title',
                    'type'    => 'select_advanced',
                    'options' => [
                        'Dr'        => __( 'Dr', 'your-text-domain' ),
                        'Professor' => __( 'Professor', 'your-text-domain' ),
                    ],
                    'columns' => 3,
                    'tab'     => 'basic_info_tab',
                ],
                [
                    'name'    => __( 'First Name', 'your-text-domain' ),
                    'id'      => $prefix . 'first_name',
                    'type'    => 'text',
                    'columns' => 4,
                    'tab'     => 'basic_info_tab',
                ],
                [
                    'name'    => __( 'Last Name', 'your-text-domain' ),
                    'id'      => $prefix . 'last_name',
                    'type'    => 'text',
                    'columns' => 5,
                    'tab'     => 'basic_info_tab',
                ],
                [
                    'name'     => __( 'Pronouns', 'your-text-domain' ),
                    'id'       => $prefix . 'user_pronouns',
                    'type'     => 'text',
                    'datalist' => [
                        'id'      => '6246d622ab80c',
                        'options' => [
                            'He/Him
    ',
                            'She/Her
    ',
                            'They/Them',
                        ],
                    ],
                    'tab'      => 'basic_info_tab',
                ],
                [
                    'name'    => __( 'Nationality', 'your-text-domain' ),
                    'id'      => $prefix . 'user_nationality',
                    'type'    => 'select_advanced',
                    'options' => [
                      //removed these to shorten 
                    ],
                    'tab'     => 'basic_info_tab',
                ],
                [
                    'name'          => __( 'Biography', 'your-text-domain' ),
                    'id'            => $prefix . 'description',
                    'type'          => 'textarea',
                    'desc'          => __( '1-2 sentences', 'your-text-domain' ),
                    'tooltip'       => [
                        'icon'     => 'info',
                        'position' => 'top',
                        'content'  => 'Write a sentence to introduce yourself. Keep it as short as a tweet - 280 characters.',
                    ],
                    'limit'         => 280,
                    'textarea_rows' => 4,
                    'tab'           => 'basic_info_tab',
                ],
                [
                    'name'         => __( 'Profile Picture', 'your-text-domain' ),
                    'id'           => $prefix . 'custom_avatar',
                    'type'         => 'single_image',
                    'force_delete' => true,
                    'tab'          => 'basic_info_tab',
                ],
                [
                    'name'       => __( 'University', 'your-text-domain' ),
                    'id'         => $prefix . 'academics_university',
                    'type'       => 'post',
                    'post_type'  => ['university'],
                    'field_type' => 'select_advanced',
                    'tab'        => 'academic_profile',
                ],
                [
                    'name'    => __( 'Faculty', 'your-text-domain' ),
                    'id'      => $prefix . 'faculty',
                    'type'    => 'select_advanced',
                    'options' => [
                 //removed to shorten
                    ],
                    'columns' => 6,
                    'tab'     => 'academic_profile',
                ],
                [
                    'name'    => __( 'Academic Position', 'your-text-domain' ),
                    'id'      => $prefix . 'academic_position',
                    'type'    => 'select_advanced',
                    'options' => [
                        //removed to shorten 
                    ],
                    'columns' => 6,
                    'tab'     => 'academic_profile',
                ],
                [
                    'name' => __( 'University Profile Page', 'your-text-domain' ),
                    'id'   => $prefix . 'university_profile',
                    'type' => 'url',
                    'tab'  => 'social_sharing',
                ],
                [
                    'name' => __( 'Linkedin Link', 'your-text-domain' ),
                    'id'   => $prefix . 'linkedin',
                    'type' => 'url',
                    'tab'  => 'social_sharing',
                ],
                [
                    'name'       => __( 'Twitter Handle', 'your-text-domain' ),
                    'id'         => $prefix . 'twitter',
                    'type'       => 'text',
                    'prepend'    => '@',
                    'attributes' => [
                        'pattern' => '[^()/><\\][\\\\\\x22,;|]+',
                    ],
                    'tab'        => 'social_sharing',
                ],
                [
                    'name' => __( 'Orchid Profile', 'your-text-domain' ),
                    'id'   => $prefix . 'orchid',
                    'type' => 'url',
                    'tab'  => 'social_sharing',
                ],
                [
                    'name' => __( 'Email', 'your-text-domain' ),
                    'id'   => $prefix . 'user_email',
                    'type' => 'email',
                    'tab'  => 'social_sharing',
                ],
                [
                    'name'              => __( 'Email Sharing', 'your-text-domain' ),
                    'id'                => $prefix . 'email_sharing',
                    'type'              => 'checkbox',
                    'label_description' => __( 'Include your email on your profile so members can get in touch', 'your-text-domain' ),
                    'attributes'        => [
                        'std' => 1,
                    ],
                    'tab'               => 'social_sharing',
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    I will use pastebin to share the screenshots

    #35405
    YasmineYasmine
    Participant

    Oh .. I can't share screenshots using pastebin either.

    But the email appears on the frontend form (even when coming back to it). But does not save in the metabox field on the backend - so this just shows as empty. The email does however save in the WP fields. But when the user modifies their email. It shows modified on the frontend form. But does not update the WP fields, and remains blank in the backend user profile email meta box.

    I had tried to link them with php:

    //setting default fields 
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title'  => 'Profile',
            'id'     => 'academic_profile',
            'type'   => 'user',
            'fields' => [
                [
                    'id'   => 'first_name', 
                    'name' => 'First Name',
                    'type' => 'text',
                ],
                [
                    'id'   => 'last_name', 
                    'name' => 'Last Name',
                    'type' => 'text',
                ],
                [
                    'id'   => 'display_name', 
                    'name' => 'Display Name',
                    'type' => 'text',
                ],
                [
                    'id'   => 'description', 
                    'name' => 'Biography',
                    'type' => 'textarea',
                ],
    			[
    				'id'    => 'user_email',
    				'name'   => 'Email',
    			 'type' => 'email',
                ],
    		
            ],
        ];
        return $meta_boxes;
    } );

    Do you think this could be an issue as I am not registering the user using meta box, but by another way?

    #35406
    YasmineYasmine
    Participant

    Update: I just created a flow through a metabox user register and login to test. And it did not fix it. Same problem

    #35423
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You are using the field id user_email to override the default user email field. So it will only display on the frontend. On the backend, you can see the default email field updated.

    Please note that, if you use the custom fields to update default fields, the custom fields will not work or display properly on the backend because they have same IDs. You can try to use another field ID to re-check this.

    #35558
    YasmineYasmine
    Participant

    You're right. And I guess it doesn't matter if the default then updates. I can echo that value instead

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.