php – Custom profile image after featured / thumbnail sharing

I disabled the gravatar option, and put the code so the user can upload the required code without a gravatar account.

Here is the full code:

   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' );


    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' ] );

The question is, can I use the profile image as a feature (thumbnail) when I share a link to a user page? It is now showing “empty / default” gravity.

Add a Comment

Your email address will not be published. Required fields are marked *