Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @devksec,

    Thanks for reaching out. The image in the post you linked to is no longer available. Could you please re-share so we can understand the problem?

    Thread Starter dev

    (@devksec)

    Hello,

    I can send one via email but the issue is the trainer pages page title showing as ” Blog – (Name of Website).” . There’s no way to resolve this within yoast or change them either.

    Thread Starter dev

    (@devksec)

    This affects all profile pages, not just trainers but also students.


    Here is some code as a workaround but there are a few things to note:

    1. I’ve not been able to override the yoast og:description with the profile biography
    2. the cover photo is the featured image, else there it uses the profile image

    // Override the Yoast SEO Open Graph title for Tutor LMS profile pages
    add_filter(‘wpseo_opengraph_title’, ‘custom_tutor_lms_og_title’, 99);
    function custom_tutor_lms_og_title($title) {
    if (is_tutor_profile_page()) {
    $user = get_current_profile_user();
    if ($user) {
    $profile_name = $user->display_name;
    $site_name = get_bloginfo(‘name’);
    return $profile_name . ‘ – ‘ . $site_name;
    }
    }
    return $title;
    }

    // Override the Yoast SEO Open Graph URL for Tutor LMS profile pages
    add_filter(‘wpseo_opengraph_url’, ‘custom_tutor_lms_og_url’, 99);
    function custom_tutor_lms_og_url($url) {
    if (is_tutor_profile_page()) {
    $user = get_current_profile_user();
    if ($user) {
    return home_url(‘/profile/’ . $user->user_nicename . ‘/’);
    }
    }
    return $url;
    }

    // Override the Yoast SEO Open Graph image for Tutor LMS profile pages
    add_filter(‘wpseo_opengraph_image’, ‘custom_tutor_lms_og_image’, 99);
    function custom_tutor_lms_og_image($image) {
    if (is_tutor_profile_page()) {
    $cover_photo = get_tutor_profile_cover_photo();
    if ($cover_photo) {
    return $cover_photo;
    } else {
    $profile_photo = get_tutor_profile_photo();
    if ($profile_photo) {
    return $profile_photo;
    }
    }
    }
    return $image;
    }

    // Helper function to check if we are on a Tutor LMS profile page
    function is_tutor_profile_page() {
    return (strpos($_SERVER[‘REQUEST_URI’], ‘/profile/’) !== false);
    }

    // Helper function to get the current profile user based on the URL
    function get_current_profile_user() {
    $profile_slug = trim(parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH), ‘/’);
    $profile_parts = explode(‘/’, $profile_slug);

    if (count($profile_parts) > 1 && $profile_parts[0] === 'profile') {
        return get_user_by('slug', $profile_parts[1]);
    }
    return null;

    }

    // Helper function to get the Tutor LMS profile cover photo URL
    function get_tutor_profile_cover_photo() {
    $user = get_current_profile_user();
    if ($user) {
    $cover_photo = get_user_meta($user->ID, ‘_tutor_cover_photo’, true);
    if (is_numeric($cover_photo)) {
    // If the cover photo is a media ID, get the actual URL
    $cover_photo_url = wp_get_attachment_url($cover_photo);
    if ($cover_photo_url) {
    return esc_url($cover_photo_url);
    }
    } elseif ($cover_photo) {
    // If it’s already a URL
    return esc_url($cover_photo);
    }
    }
    return null;
    }

    // Helper function to get the Tutor LMS profile photo URL (as a fallback if cover photo is not set)
    function get_tutor_profile_photo() {
    $user = get_current_profile_user();
    if ($user) {
    $profile_photo = get_user_meta($user->ID, ‘_tutor_profile_photo’, true);
    if (is_numeric($profile_photo)) {
    // If the profile photo is a media ID, get the actual URL
    $profile_photo_url = wp_get_attachment_url($profile_photo);
    if ($profile_photo_url) {
    return esc_url($profile_photo_url);
    }
    } elseif ($profile_photo) {
    // If it’s already a URL
    return esc_url($profile_photo);
    }
    // Fallback to WordPress avatar if no profile photo is set
    return get_avatar_url($user->ID);
    }
    return null;
    }



    here is part of the bio code which was not working

    $bio = get_tutor_profile_biography(); if ($bio) { echo ‘<meta property=”og:description” content=”‘ . esc_attr(wp_strip_all_tags($bio)) . ‘”>’ . PHP_EOL; } else {

    Thread Starter dev

    (@devksec)

    Is there any update to when this will be fixed? YoastSEO has support for TutorLMS but it seems these pages have been missed off the integration.

    Thread Starter dev

    (@devksec)

    Any update?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.