BuddyDev

Search

Copy Url to clipboard button for an individual post.

  • Participant
    Level: Initiated
    Posts: 7
    Web Buddy on #55681

    Hello Buddydev

    I have recieved email complants from visitors who don’t know how to get the url for an individual post.

    At the top of each Buddypress post is a time posted link with a url that will create a page with only that post on it.

    Example == -User123- posted an update (a day ago)

    Example == https://buddypress-site.com/activity-page/p/8803/

    Is it possible to put some code into “bp-custom.php” or “functions.php” that would make a copy to clip board button for visitors that are not logged in ?

    Thank You
    webbuddy

  • Keymaster
    (BuddyDev Team)
    Posts: 25090
    Brajesh Singh on #55682

    Hi,
    Welcome to BuddyDev.

    It is certainly doable. How to do it will depend on theme/template pack you are using.

    You will need to do the following:-

    1. Load a js file like ClipBoard.js – https://clipboardjs.com/
    2. Inject the button for copying (most of the time using bp_activity_entry_meta action)
    3. Enable the copy

    There is a minor issue that you will face when new activity is posted on current page, you will need to activate this copy js again for that specific activity.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25090
    Brajesh Singh on #55683
    This reply has been marked as private.
  • Participant
    Level: Initiated
    Posts: 7
    Web Buddy on #55686

    Hey Brajesh

    Hey , Thanks for the great reply. I’ll look into that, but —

    maybe there’s an easer way ? — A link button, or just some link text that would appear

    below the post for logged and non-logged in users. Then users could right click menu to

    get the Url. Could that be done functions code ?

    ——–
    ——–

    On that — other thing, I’ll try to find one that doesn’t require a phone. Thats not going to be easy.

    Thank You
    WebBuddy

    • This reply was modified 6 days, 11 hours ago by Web Buddy.
  • Keymaster
    (BuddyDev Team)
    Posts: 25090
    Brajesh Singh on #55689

    Hi,
    Try adding the following code to your functions.php or bp-custom.php

    https://gist.github.com/sbrajesh/ed8298d085f6b58e1838f6f4db97d877

    It would add a “Link” text to each post and clicking on it, users can access the permalink.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Web Buddy on #55691

    Hi Brajesh

    Thank you, your awesome ! — I’ll apply that code and get back to you.
    —-
    —-
    still on the other thing, —– the internet isn’t what it used to be.

    Thanks
    WebBuddy

  • Keymaster
    (BuddyDev Team)
    Posts: 25090
    Brajesh Singh on #55692

    You are welcome.
    I am looking forward to your fedeback.

    About the email:- My main concern is that someone may access it and reset your account’s pass and do something undesirable(spam). That’s why I suggested changing it.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Web Buddy on #55694

    Hi Brajesh

    That code worked great !

    The link appeared with the others below the post with ‘ comment ‘ favorite’ ect.

    I looked at it with the browsers web developer. You already know this but here is the html

    div container it operates in

    <div class=”activity-meta”>

    this is the permalink function in that container

    <a href=”https://buddypress123.com/activity-page/p/8816/&#8221; target=”_blank”

    class=”bp-activity-permalink”>Link

    Is there a way to give the new link a logged in exception ? It disappears with the
    other functions when non-logged in visitors view the activity feed.

    ————————–

    ————————–

    The mail address and password for this account are only used here. It’s unlikely
    anyone is going to get in

    I tried to add a number sequence to the mail address that for practical purposes becomes
    the mail service account password. Got a red banner – ” settings have been changed ” but it didn’t change.

    ————–

    ————–

    Thank You
    WebBuddy

    • This reply was modified 1 day, 17 hours ago by Web Buddy.

You must be logged in to reply to this topic.

This topic is: not resolved