• 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 2 years, 7 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.