• Resolved vitoradler

    (@vitoradler)


    I’m trying to create a shortcode that fetch the user’s cover photo but i don’t know why it isn’t working. I’m using this code now:

        add_shortcode('link_cover_perfil', 'generate_cover_link');
    
    function generate_cover_link() {
        // Check if Ultimate Member plugin is active
        if (function_exists('um_user')) {
            // Get the current user's ID
            $user_id = um_user('ID');
            um_fetch_user($user_id);
    
            // Get the avatar URL for the user
            $cover_url = get_user_meta( $user_id, 'cover_photo', true );
    
            // Check if avatar URL is found
            if (!empty($cover_url)) {
                // Return the img tag with avatar URL
                $res = "<img src=\"{$avatar_url}\" style=\"width: 100%; height:400px;\"/>";
    
                return $res;
            } else {
                return "URL da imagem de capa de perfil n?o encontrada para o usuário atual.";
            }
        } else {
            return "Ultimate Member plugin n?o está instalado ou ativado.";
        }
    }

    My final goal is to show this cover as a div background image and the user’s name in front of it.

    PS:. mature content page (NSFW)

    The page I need help with: [log in to see the link]

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

    (@kainelabsteam)

    Hi @vitoradler

    Thank you for reaching us.

    Unfortunately, at the moment, there’s no way to show a single Profile Page or only part of it (i.e. cover image) with a shortcode.

    Best Regards, KaineLabs Team.

    Thread Starter vitoradler

    (@vitoradler)

    is there ate least a way to get the cover image Url?

    Plugin Support Youzify

    (@kainelabsteam)

    Hi @vitoradler

    Do you mean you want to know where the cover image was uploaded and stored? If yes, it is stored in the folder:

    “yourwebsite.com/wp-content/uploads/buddypress/members/”

    Best Regards, KaineLabs Team.

    Thread Starter vitoradler

    (@vitoradler)

    hello again!

    I’ve solve the problem with the following snippet:

    add_shortcode('link_cover_perfil', 'generate_cover_link');
    
    function generate_cover_link() {
    // Check if Ultimate Member plugin is active
    if (function_exists('um_user')) {
    // Get the current user's ID
    $user_id = um_profile_id();
    um_fetch_user( $user_id );
    
    // Get the URL for the user's cover photo
           $cover_url = sprintf('https://scortvip.vitoradler.com/wp-content/uploads/ultimatemember/%s/cover_photo.png', $user_id);
    
        // Check if cover photo URL is found
        if (!empty($cover_url)) {
            // Return the img tag with cover photo URL
            $res = "<img src=\"{$cover_url}\" style=\"width: 100%; height: 400px;\"/>";
            return $res;
        } else {
            return "Capa de perfil n?o encontrada para o usuário atual.";
        }
    } else {
        return "Ultimate Member plugin n?o está instalado ou ativado.";
    }
    }

    and just need to place the shortcode [link_cover_perfil] anywere on the website

    • This reply was modified 6 months ago by vitoradler. Reason: Forgot to mark as solved
    Plugin Support Youzify

    (@kainelabsteam)

    Hello @vitoradler

    Wow, amazing! Thank you very much for sharing this with us. And I am glad to hear you have sorted the requirements by yourself.

    Best Regards, KaineLabs Team.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[NSFW] creating a shortcode for cover photo’ is closed to new replies.