Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 226 through 240 (of 244 total)
  • Author
    Posts
  • in reply to: Profile picture not showing in elementor template #34193
    YasmineYasmine
    Participant

    Rather than duplicating the value, can't I do what I did for post_content etc and make my custom field "profile_picture" the default WP field?

    in reply to: Profile picture not showing in elementor template #34192
    YasmineYasmine
    Participant

    Hi Long - but its not working on my site. Have others had this problem when trying to create a custom field for profile for elementor templates?? I think the incompatibility is with elementor? I have the meta box - elementor plugin installed.

    What do you suggest I do to fix it?

    I have also noticed that if all the values are empty (there are no profile pictures saved in that custom field then the error does not occur - its only when adding values into the custom field that it shows!

    in reply to: Profile picture not showing in elementor template #34141
    YasmineYasmine
    Participant

    Thank you Long. Custom fields 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',
            'tab_style' => 'box',
            '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 . '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'      => '6218edf305a2b',
                        'options' => [
                            'He/His
    ',
                            'She/Hers
    ',
                            'They/Them',
                        ],
                    ],
                    'tab'      => 'basic_info_tab',
                ],
                [
                    'name'     => __( 'Nationality', 'your-text-domain' ),
                    'id'       => $prefix . 'user_nationality',
                    'type'     => 'text',
                    'datalist' => [
                        'id'      => '6218edf305a41',
                        'options' => [
             
    ',//just took these options out as very long list
                        ],
                    ],
                    'tab'      => 'basic_info_tab',
                ],
                [
                    'name'  => __( 'Biography', 'your-text-domain' ),
                    'id'    => $prefix . 'description',
                    'type'  => 'text',
                    'desc'  => __( 'One sentence - keep it short and snappy', 'your-text-domain' ),
                    'limit' => 280,
                    'tab'   => 'basic_info_tab',
                ],
                [
                    'name'         => __( 'Profile Picture', 'your-text-domain' ),
                    'id'           => $prefix . 'profile_picture',
                    'type'         => 'single_image',
                    'force_delete' => true,
                    'tab'          => 'basic_info_tab',
                ],
                [
                    'name'       => __( 'University', 'your-text-domain' ),
                    'id'         => $prefix . '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 these
                    ],
                    'columns' => 6,
                    'tab'     => 'academic_profile',
                ],
                [
                    'name'    => __( 'Academic Position', 'your-text-domain' ),
                    'id'      => $prefix . 'academic_position',
                    'type'    => 'select_advanced',
                    'options' => [
                 //removed options
                    ],
                    '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' => '@',
                    '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'              => 'switch',
                    'label_description' => __( 'Allow others to contact you', 'your-text-domain' ),
                    'on_label'          => 'On',
                    'off_label'         => 'Off',
                    'std'               => true,
                    'tab'               => 'social_sharing',
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    

    And the code for the filter:

    
    add_filter( 'get_avatar_url', 'mbua_get_avatar_url', 10, 3 );
    
    function mbua_get_avatar_url( $url, $id_or_email, $args ) {
        if ( is_numeric( $id_or_email ) ) {
            $user_id = $id_or_email;
        } elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) {
            $user_id = $user->ID;
        } elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
            $user_id = (int) $id_or_email->user_id;
        }
    
        if ( empty( $user_id ) ) {
            return $url;
        }
    
        $custom_avatar = rwmb_meta( 'profile_picture', [ 'object_type' => 'user' ], $user_id );
    
           if ( ! $custom_avatar ) {
            return $url;
        }
        $url = $custom_avatar['full_url'];
        
        return $url;
    
    in reply to: Profile picture not showing in elementor template #34134
    YasmineYasmine
    Participant

    Ok. But this is a problem as the error message does not disappear. Do you have any modifications to the code where the site info is not deleted? Or do you know another reason why this might have happened when running the above code??

    in reply to: Adding metabox field data to the post title #34133
    YasmineYasmine
    Participant

    Thanks ... I don't understand how to apply the documentation - hence my question... Is this correct?

    
    add_action( 'rwmb_research-summary_after_save_post', 'update_post_content' );
    
    function update_post_content( $post_id ) {
        $my_meta = rwmb_meta( 'academicpost_content', '', $post_id );
    
    $my_post = array(
        'ID' => $post_id,
        'post_content' => $my_meta,
    );
    wp_update_post( $my_post );
    }
    
    in reply to: Adding metabox field data to the post title #34119
    YasmineYasmine
    Participant

    Thank you again Long.

    And would it be the same logic for post_content? And excerpt? Eg:

    add_action( 'rwmb_research-summary_after_save_post', 'update_post_content' );
    
    function update_post_title( $post_id ) {
        // Get the field value
        $my_meta = rwmb_meta( 'academicpost_content', '', $post_id );
    
    // Prepare update post
    $my_post = array(
        'ID' => $post_id,
        'post_content' => $my_meta,
    );
    wp_update_post( $my_post );
    }
    
    in reply to: Profile picture not showing in elementor template #34118
    YasmineYasmine
    Participant

    I thought I had worked out the error message, and thought it was because I had not used the prefix (making my id 'academicprofile_picture') - while that got rid of the error message, it also stopped it from working!

    Would you mind deleting my error code once you've seen it?

    Thank you!

    in reply to: Profile picture not showing in elementor template #34116
    YasmineYasmine
    Participant

    Perfect - it works.

    However I now see this error message "
    Warning: Illegal string offset 'full_url' in ...functions.php on line 117

    --> should I not be saving in my child theme php but somewhere else?

    in reply to: Adding metabox field data to the post title #34107
    YasmineYasmine
    Participant

    Hi Long,

    I just saw your reply. Thank you. Here is my PHP:
    https://pastebin.com/BUunL5vK

    in reply to: Profile picture not showing in elementor template #34106
    YasmineYasmine
    Participant

    I think I have the same issue for first name, last name, biography and email too..

    in reply to: Profile picture not showing in elementor template #34105
    YasmineYasmine
    Participant

    https://pastebin.com/HhRKJaNc

    in reply to: Adding metabox field data to the post title #34045
    YasmineYasmine
    Participant

    Hi Long,

    I am also trying to do this. But I need some help with the above sample code and documentation. Can you possibly indicate which elements I need to customise and with exactly what. It is really helpful when you can add //update this variable with your meta-box-id. I am very new to this and so nothing is obvious to me.

    I will also need to do this for post excerpt and post content...

    Many thanks!
    Yasmine

    in reply to: Author meta just showing numbers #33967
    YasmineYasmine
    Participant

    Thank you Long for the reply! But I still can't get it working...

    I tried:

    {
    $post_author_id = get_post_field( 'post_author', $post_id );
    }
    $post_id = rwmb_meta( 'academics_university', ['object_type' => 'user'], $post_author_id );
    echo get_the_title( $post_id )
    ?>

    So I guess I don't know what to add in replacement to your "123" to make it work for dynamic post author. Can you advise?

    Secondly, I don't really understand when I would use field post user meta versus the relationship. How do they differ - and could you possibly provide an example of how they differ?

    It is likely that I will want to use additional fields from the related post to show in future $research templates

    Thank you - I appreciate it.

    in reply to: Author meta just showing numbers #33966
    YasmineYasmine
    Participant

    Thank you Long for the reply!

    I still can't get it working...

    I tried:

    {
    $post_author_id = get_post_field( 'post_author', $post_id );
    }
    $post_id = rwmb_meta( 'academics_university', ['object_type' => 'user'], $post_author_id );
    echo get_the_title( $post_id )
    ?>

    So I guess I don't know what to add in replacement to your "123" to make it work for dynamic post author. Can you advise?

    Secondly, I don't really understand when I would use field post user meta versus the relationship. How do they differ - and could you possibly provide an example of how they differ?

    It is likely that I will want to use additional fields from the related post to show in future $research templates

    Thank you - I appreciate it.

    in reply to: Author meta just showing numbers #33910
    YasmineYasmine
    Participant

    But the above is from the post field on the custom fields form. I also created a relationship between the user and university. And was actually not sure if this part was needed or not and how to tie it in:

    <?php
    add_action( 'mb_relationships_init', 'your_prefix_function_name' );
    
    function your_prefix_function_name() {
        MB_Relationships_API::register( [
            'id'         => 'relationship_user_university',
            'reciprocal' => true,
            'from'       => [
                'object_type' => 'user',
                'post_type'   => 'post',
                'taxonomy'    => 'category',
                'meta_box'    => [
                    'title' => 'user_to_university_relationship',
                ],
                'field'       => [
                    'name' => 'User to University Relationship',
                ],
            ],
            'to'         => [
                'object_type' => 'post',
                'post_type'   => 'university',
                'meta_box'    => [
                    'title' => 'university_to_user_relationship',
                ],
                'field'       => [
                    'name' => 'University to User Relationship',
                ],
            ],
        ] );
    }
Viewing 15 posts - 226 through 240 (of 244 total)