Tutor LMS – Get Student Information in PHP

While customizing Tutor LMS there are times where you need the student avatar, student profile URL or numbers of courses a student completed so far etc. This type of information about students can be easily fetched and then can be displayed in any widget, shortcode or template. You get any piece of information you require out of tutor_utils() function. Enjoy!

Get Tutor LMS Student Avatar

// Check if Tutor LMS exists
if ( function_exists( 'tutor_utils' ) ) {
    $tutor_user         = tutor_utils()->get_tutor_user( get_current_user_id() );
    $tutor_avatar_url   = esc_url(wp_get_attachment_image_url( $tutor_user->tutor_profile_photo, 'thumbnail' )); 

    echo $tutor_avatar_url;
}

Get Tutor LMS Student Cover URL

// Check if Tutor LMS exists
if ( function_exists( 'tutor_utils' ) ) {
    $tutor_user         = tutor_utils()->get_tutor_user( get_current_user_id() );
    $total_cover_url    = esc_url( tutor_utils()->get_cover_photo_url( $tutor_user ) );

    echo $total_cover_url;
}

Get Wishlist of a Student

// Check if Tutor LMS exists
if ( function_exists( 'tutor_utils' ) ) {
    $tutor_user             = tutor_utils()->get_tutor_user( get_current_user_id() );
    $total_wishlists_count  = count(tutor_utils()->get_wishlist($tutor_user));

    echo $total_wishlists_count;
}
Scroll to Top