• Resolved plutonash

    (@plutonash)


    Hello all code lovers on the internet : )

    So I got a problem that I hope someone can help me with.

    I want to display a specific user Profile on a page with a shortcode.

    So, I found this page in ULTIMATE MEMBERS site (https://docs.ultimatemember.com/article/1628-display-specific-profile-with-shortcode) with a code snippet that will show / display a profile on a page.

    But I dont have the skills to understand how to make it work : (

    I have paste the snippet into my function.php file, and then I paste this shortcode into a page: [um_embed_profile user_id=”264″ form_id=”264″].

    (The number 264 is the profiles ID and the Profile Form ID number. I also got a User ID roll = um_demo-tjej. But none works for me.)

    So, must I add something into the snippet, or do the shortcode have wrong ID ?

    I do hope there is someone here that have the skills to solve this problem for me.

    Best Regards

    / Pluto Nash

Viewing 7 replies - 1 through 7 (of 7 total)
  • @plutonash

    I tested the code snippet and it works OK at my site with this shortcode and code:

    [um_embed_profile user_id="2" form_id="1698"]

    /**
     * Sample usage: [um_embed_profile user_id="123" form_id="3"]
     */
    add_shortcode("um_embed_profile","um_082321_embed_specific_profile");
    function um_082321_embed_specific_profile( $atts ){
    
        $atts = shortcode_atts( array(
            'user_id' => get_current_user_id(),
            'form_id' => 0,
        ), $atts );
       extract( $atts );
    
        UM()->user()->target_id = $user_id;
        $value = "[ultimatemember form_id='{$form_id}']";
        if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
            return do_shortcode( $value );
        } else {
            return apply_shortcodes( $value );
        }
    }

    Make sure that you don’t have any page builder formatting around the shortcode and that your shortcode and code snippet is using the right version of double quotes.

    Thread Starter plutonash

    (@plutonash)

    Hello MissVeronica !

    Here is a fast reply from Pluto about your replie to my code snippet problem.

    I saw on GitHub that we both are from same country and city, so I will now let the rest om my reply be in our native language so that I easier can explain the things I have done and so on. Hope thats ok for you and all other ? !

    Först vill jag med stort hjärta tacka för att du valde att vilja kolla min tråd här inne på detta forum samt prova /testa den kod-string som jag funnit som ska visa en UM profil på en separat sida (page), det är mycket uppskattat.

    BAKGRUND
    Så, jag har byggt en liten hemsida där jag har installerat Ultimate Member och allt funkar utan problem. Totalt har jag skapat 6 st. olika användarroller som enbart inloggade medlemmar ska kunna se / besöka. Sen har jag valt att skapa 2 st. DEMO roller / profiler som ska gå att se om man är besökande gäst på hemsidan. Detta för att visa hur en medlemsprofil ser innan man ev. väljer att bli medlem på sidan.

    Som du vet så skapar Ultimate Member vid installationen en egen sida (page) som heter Användare (UM-Användare) och där lägger jag alla shortcodes för dom olika Profilformulär som jag skapat för samtliga användarroller. För att inte utomstående skall kunna se / besöka de medlemmar som hemsidan har så har jag på sidan (page) Användare (UM-Användare) längst ner valt Who can access this post? = Endast inloggade medlemmar.

    PROBLEMET
    Så jag har skapat 2 DEMO profiler som besökande gäster av hemsidan ska kunna se. Men om jag lägger shortcoden för dessa profiler på sidan Användare (UM-Användare) så kan dessa EJ ses med ovan nämnd inställning. Efter en del sökning på nätet hur man kan visa en specifik profil på en separat sida (page) så fann jag den kod-string som du så vänligt har testat. Dock får jag tyvärr inte detta att funka : (

    MIN INSTÄLLNING
    Jag har lagt in kod-stringen (code snippet) i functions.php som finns i min themes mapp och sen har jag i WordPress Back-End skapat en sida (page) som fick namnet Demo-Profil där jag lagt in din shortcode ([um_embed_profile user_id=”2″ form_id=”1698″]). Inställningen för sidan (page) är att Alla har access till den.

    Dock är jag osäkert vart jag finner user_id och form_id till shortcoden. Jag antar att form_id är det profilformulär som jag skapat för DEMO profilerna, och att user_id är det Roll-ID som finns på sidan Ultimate Memeber – Användarroller ?

    Men det som förbryllar mig är att din shortcode och även den som finns med i “snippet” har user_id ett nummer (user_id=”2″). Mina användarroller har inte nummer utan titel / namn efter det som jag döpt varje användarroll till.

    Min fråga är vart man hittar user_id numret ? Eller är det titeln / namnet på min användarroll som är user_id ? (I detta fall heter användarrollen um_demo-profil). Samt är form_id det nummer som användarens profilformulär har ([ultimatemember form_id=”264″]) dvs. i detta fall “264”. ?

    AVSLUTNINGSVIS
    Så, jag har således denna shortcode: [um_embed_profile user_id=”um_demo-profil” form_id=”264″]. Denna har jag lagt in på en separat sida som jag skapat i Back-End som heter Demo-Profil. Besöker jag sen hemsidan från annan webbläsare så kan jag EJ se den aktuella profilen.

    Beklagar ett långt utlägg på mitt problem. Jag hoppas att dessa rader ger en bra sammanfattning och att ni kanske har svar på vart jag kan hitta user_id och form_id nummer till min shortcode som gör att detta snippet funkar.

    Sist vill jag åter tacka för att ni testade den aktuella snippet, dock så får jag det som sagt inte att fungera : ( Är därför tacksam för svar som kan ge en lösning på mitt aktuella problem.

    Varma sommarhälsningar från metropolen Sthlm

    / Pluto

    @plutonash

    The Form ID you can get when listing UM Forms and look at the ID column.

    WP Users -> All Users and click on the User profile and look at the URL where you will find the user_id parameter value.

    Thread Starter plutonash

    (@plutonash)

    Thanks MissVeronica for your reply, but it did not solve my problem.

    Is WP Users a plugin so I can get a user_id number ?

    I just can find a user_id number for my users, they all have namnes not numbers. If I look at the url string for a profile in a web browser it have no number, just the profile name like this: /?page_id=17&um_user=demo-profile

    So, this snippet does not work for me ! Unless someone can tell me where to find the user_id number…

    Best Regards

    / Pluto Nash

    @plutonash

    Change your “Profile Permalink Base” to User ID in
    UM Settings -> General -> Users
    and you will have user ID in all user URLs.

    • This reply was modified 3 years, 10 months ago by missveronica.
    Thread Starter plutonash

    (@plutonash)

    Hi again MissVeronica : )

    I just want to say thanks for your great support and help. A big heart 2 you, and lots of thanks for helping me out with this. Because now it works, and I love it : )

    Your advise to change the UM parmalink solved it. I am so glad right now, and once again a big thanks for this help. You are the BEST !

    Best Regards from 142 Sthlm

    / Pluto Nash

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know how it resolved your issue.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘HOW DO I MAKE THIS CODE SNIPPET WORK ? !’ is closed to new replies.