BuddyDev

Search

[Resolved] Prevent Hyperlinks in the BuddyPress Activity

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #7877

    Hi, there

    Thanks for the helps before and I’m very appreciated about that.

    I just met an issue that in my site, for the purpose of safety, external links shouldn’t be allowed to post into the activity. But currently, by default, when users copy and paste any external links into the activity, the system will recognize the hyperlinks and for Youtube links, it can display videos directly.

    I’m wondering that is there any way to don’t allow users to type in hyperlinks in the activity?

    Thank you very much.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #7891

    Hi Dandy,

    Thank you for asking,.

    There are two things involved here.

    1. Oembed:- The generated content you see
    2. Hyperlinked:- All other links that don’t support oembed

    Do you want to disable both?

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #7892

    Hi, Brajesh

    Yes, I want to disable both of them.

    Thanks.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #7894

    Hi Dandy,
    Please put this in your bp-custom.php and let me know it works for you or not?

    
    add_filter( 'bp_use_oembed_in_activity', '__return_false' );
    
    

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #7895

    Hi, Brajesh

    I tested this code. However, it only disables the embed content, but the hyperlink still be clickable. Can you find a way to disable the external hyperlinks as well?

    Thanks.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #7897

    Hi Dandy,
    Thank you.
    yes, that was only for oembed.

    Please add this to the bp-custom.php

    
    function buddydev_disable_activity_links() {
    
    	remove_filter( 'bp_get_activity_action',                'make_clickable', 9 );
    	remove_filter( 'bp_get_activity_content_body',          'make_clickable', 9 );
    	remove_filter( 'bp_get_activity_content',               'make_clickable', 9 );
    	remove_filter( 'bp_get_activity_parent_content',        'make_clickable', 9 );
    	remove_filter( 'bp_get_activity_latest_update',         'make_clickable', 9 );
    	remove_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable', 9 );
    }
    
    add_action( 'bp_template_redirect', 'buddydev_disable_activity_links' );
    

    Please do let me know how it goes.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #7901

    Hi, Brajesh

    Thanks for your solution.

    I tested it, however, it seems like the hyperlinks still can be posted in the activity.

    And the first time it’s still clickable, when I click it, then, it becomes pure text.

    Thanks.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #7902

    Ahh, sorry. I forgot about the first time ajax posting part.

    Please change ‘bp_template_redirect’ to ‘bp_init’

    That will do it.

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #7966

    Hi, Brajesh

    Sorry to reply you late. I used the updated code and it worked perfectly.

    Thank you very much.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #8032

    You are welcome Thank you for confirming Dandy 🙂

You must be logged in to reply to this topic.

This topic is: resolved