Support Forum ยป User Profile

Forum Replies Created

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • Johannes GrossJohannes Gross
    Participant

    Thank you Anh for taking care of it so quickly! Appreciate it.

    in reply to: โœ…Get User email info in Custom post meta #16303
    Johannes GrossJohannes Gross
    Participant

    Run into it and ended up using something like following to be able to have users update their email address in the frontend:

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title'  => '',
            'id'     => 'edit_user_profile',
            'type'   => 'user',
            'fields' => [
                [
                    'id'   => 'first_name',
                    'name' => 'First Name',
                    'type' => 'text',
                ],
                [
                    'id'   => 'last_name',
                    'name' => 'Last Name',
                    'type' => 'text',
                ],
                [
                    'id'   => 'twt_user_email',
                    'name' => 'Email',
                    'type' => 'email',
                    'save_field' => false
                ],
            ],
        ];
        return $meta_boxes;
    } );
    //hide user profile metabox in backend (otherwise duplicate)
    add_filter( 'rwmb_show_edit_user_profile', '__return_false' );
    //populate twt_user_email
    add_filter('rwmb_twt_user_email_field_meta', function($meta, $field, $saved) {
        $user = wp_get_current_user();
        return $user->user_email;
    }, 10, 3);
    //update users email upon profile update
    add_filter('rwmb_profile_update_user_data', function($data, $config ) {
        $data['user_email'] = sanitize_email($_POST['twt_user_email']);
        return $data;
    }, 10, 2);
    in reply to: โœ…Image Advanced Order Not Saving #15933
    Johannes GrossJohannes Gross
    Participant

    Again, thanks for fixing the Image Advanced field. This is now working great.
    However, today I noticed that in a cloneable group block, the order does not save (e.g. changes back when reloading).

    Here is the code I am using:

    add_action('rwmb_meta_boxes', 'twt_metabox_io_blocks');
    function twt_metabox_io_blocks($meta_boxes) {
        $meta_boxes[] = array(
            'id'         => 'twt-people-block',
            'title'      => 'TWT People Block',
            'type'            => 'block',
            'icon'            => 'admin-users',
            'category'        => 'formatting',
            'context'         => 'side',
            'render_callback' => 'render_twt_people_block',
            'supports' => array(
                'anchor' => true,
                'customClassName' => true,
            ),
            'fields' => array(
                array(
                    'name' => '',
                    'id'   => 'people',
                    'type' => 'group',
                    'clone'  => true,
                    'sort_clone' => true,
                    'fields' => array(
                        array(
                            'name' => 'Photo',
                            'desc' => 'Ideal size: 200px x 200px',
                            'id'   => 'image',
                            'type' => 'single_image',
                        ),
                        array(
                            'name' => 'Caption (e.g. Person\'s Name)',
                            'id'   => 'caption',
                            'type' => 'textarea',
                            'rows' => 2
                        ),
                    )
                )
            )
        );
        return $meta_boxes;
    }
    function render_twt_people_block($attr, $is_preview = false, $post_id = null) {
        if ( empty( $attr['data'] ) ) {
            return;
        }
    
        // Unique HTML ID if available.
        $id = 'twt_people-' . ( $attr['id'] ?? '' );
        if ( ! empty( $attr['anchor'] ) ) {
            $id = $attr['anchor'];
        }
    
        // Custom CSS class name.
        $class = $attr['className'] ?? '';
        if ( ! empty( $attr['align'] ) ) {
            $class .= " align{$attr['align']}";
        }
    
        if(isset($attr['data']['people'])) {
    ?>
    ">
        
        
                    
                        
                            
                            
                                
                            
                        
                    
                    <?php
                }
        ?>
        </div>
    </div>
    <?php
        }
    }
    

    I know the caption field is kind of redundant... ๐Ÿ˜‰

    Thanks for checking into it...

    in reply to: โœ…Image Advanced Order Not Saving #15906
    Johannes GrossJohannes Gross
    Participant

    Thank you!

    in reply to: โœ…Anchor not saving #15873
    Johannes GrossJohannes Gross
    Participant

    Great! Thank you for your reply and for staying on top of this!

Viewing 5 posts - 16 through 20 (of 20 total)