Custom profile image as featured/thumbnail after share

  css, html, jquery, php

I disabled gravatar option, and putted code so user can upload custom code without having gravatar account

Full code is here:

   add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );

function my_show_extra_profile_fields( $user ) 
{ 
?>
    
            <img class="user-preview-image" src="<?php echo esc_attr(get_the_author_meta( 'sidebarimage', $user->ID ) ); ?>">

            <input type="text" name="sidebarimage" id="sidebarimage" value="<?php echo esc_attr( get_the_author_meta( 'sidebarimage', $user->ID ) ); ?>" class="regular-text" />
            




    add_action( 'admin_enqueue_scripts', 'enqueue_admin' );

    function enqueue_admin()
    {
    wp_enqueue_script( 'thickbox' );
    wp_enqueue_style('thickbox');

    wp_enqueue_script('media-upload');
    }

    add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );

    function my_save_extra_profile_fields( $user_id ) {

    if ( !current_user_can( 'edit_user', $user_id ) )
    {
    return false;
    }

    update_user_meta( $user_id, 'image', $_POST[ 'image' ] );
    update_user_meta( $user_id, 'sidebarimage', $_POST[ 'sidebarimage' ] );
    }

Question is, can I use profile image as featured (thumbnail) when I share link of user page? Now it showing "empty/default" gravatar

Source: Ask PHP

LEAVE A COMMENT