$author_email = get_the_author_meta( 'user_email' );
$user = get_user_by( 'email', $author_email );
$userId = $user->ID;
$post_count = count_user_posts( $userId );
// Handle form submission
if (isset($_POST['submit_profile_update']) && wp_verify_nonce($_POST['_wpnonce'], 'update_user_info')) {
// Update user information
$user_data = array(
'ID' => get_current_user_id(),
'first_name' => sanitize_text_field($_POST['first_name']),
'last_name' => sanitize_text_field($_POST['last_name']),
'display_name' => sanitize_text_field($_POST['display_name']),
'description' => sanitize_textarea_field($_POST['user_bio'])
);
wp_update_user($user_data);
$user_avatar_image_url = sanitize_text_field($_POST['selected-avatar-image-url']);
// Update user meta for phone number
$phone_number = sanitize_text_field($_POST['phone_number']);
update_user_meta(get_current_user_id(), 'phone_number', $phone_number);
// Update user meta for show_email and show_number options
update_user_meta(get_current_user_id(), 'show_email', isset($_POST['show_email']) ? 'yes' : 'no');
update_user_meta(get_current_user_id(), 'show_number', isset($_POST['show_number']) ? 'yes' : 'no');
update_user_meta( get_current_user_id(), 'user_facebook', sanitize_text_field($_POST['user_facebook'] ));
update_user_meta( get_current_user_id(), 'user_instagram', sanitize_text_field($_POST['user_instagram'] ));
update_user_meta( get_current_user_id(), 'user_twitter', sanitize_text_field($_POST['user_twitter'] ));
update_user_meta( get_current_user_id(), 'user_linkedin', sanitize_text_field($_POST['user_linkedin'] ));
update_user_meta( get_current_user_id(), 'user_google', sanitize_text_field($_POST['user_google'] ));
update_user_meta( get_current_user_id(), 'user_youtube', sanitize_text_field($_POST['user_youtube'] ));
update_user_meta( get_current_user_id(), 'user_whatsapp', sanitize_text_field($_POST['user_whatsapp'] ));
update_user_meta( get_current_user_id(), 'user_other', sanitize_text_field($_POST['user_other'] ));
update_user_meta( get_current_user_id(), 'custom_avatar_url', $user_avatar_image_url);
if(isset($_POST['delete_avatar'])){
delete_user_meta(get_current_user_id(), 'custom_avatar_url');
}
}
$showEmail = get_user_meta($userId, 'show_email', true);
$showPhone = get_user_meta($userId, 'show_number', true);
User Social Media Links