Default WordPress Image Upload function instead of Gravatar link

I am a WordPress Newbie, I was setting up my tour website and i was trying to figure out an issue in user edit profile page. In the edit profile page template, there is an button to upload profile photo but that is currently a static button pointed to Gravatar website. But I wanted to replace it will a default WordPress media upload function so that Users can upload their profile pictures in their profiles. Please check the template codes below and assist me to add that function/hook to achieve the result. If I add the picture from admin area then it shows in the profile page but to add from user end, there is no active function to allow. So please assist me.

$profile_fields = tourmaster_get_profile_fields();

echo ‘<div class=”tourmaster-user-content-inner tourmaster-user-content-inner-edit-profile” >’;

// update data
if( isset($_POST[‘tourmaster-edit-profile’]) ){
$verify = tourmaster_validate_profile_field($profile_fields);

if( is_wp_error($verify) ){
$error_messages = ”;
foreach( $verify->get_error_messages() as $messages ){
$error_messages .= empty($error_messages)? ”: ‘<br />’;
$error_messages .= $messages;
tourmaster_user_update_notification($error_messages, false);
tourmaster_user_update_notification(esc_html__(‘Your profile has been successfully changed.’, ‘tourmaster’));

// edit profile page content
echo ‘<form class=”tourmaster-edit-profile-wrap tourmaster-form-field” method=”POST” >’;

echo ‘<div class=”tourmaster-edit-profile-avatar” >’;
echo get_avatar($current_user->data->ID, 85);
echo ‘<a class=”tourmaster-button” href=”” target=”_blank” >’ . esc_html__(‘Change Profile Picture’, ‘tourmaster’) . ‘</a>’;
echo ‘</div>’;

foreach( $profile_fields as $slug => $profile_field ){
$profile_field[‘slug’] = $slug;
tourmaster_get_form_field($profile_field, ‘profile’);

echo ‘<input type=”submit” class=”tourmaster-edit-profile-submit tourmaster-button” value=”‘ . esc_html__(‘Update Profile’, ‘tourmaster’) . ‘” />’;
echo ‘<input type=”hidden” name=”tourmaster-edit-profile” value=”1″ />’;
echo ‘</form>’; // tourmaster-edit-profile-wrap

echo ‘</div>’; // tourmaster-user-content-inner

Read more here:: Default WordPress Image Upload function instead of Gravatar link

Leave a Reply

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