Skip to:
Content
Pages
Categories
Search
Top
Bottom

Enable shortcode in BuddyPress activity feed


  • Fábio Roque
    Participant

    @fabioroque92

    Hi everyone, I already try some solutions like

    add_filter( ‘bp_nouveau_activity_content’, ‘do_shortcode’,);

    or

    function test() {
    add_filter( ‘bp_nouveau_activity_content’, ‘do_shortcode’, 1 );
    }
    add_action(‘bp_init’, ‘test’);

    But I can’t solve this problem, somebody knows how to enable the shortcodes in activity feed? thnks

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

  • shanebp
    Moderator

    @shanebp

    That is not how shortcodes work.
    You need to put it in the template:
    buddypress\bp-templates\bp-nouveau\buddypress\activity\entry.php
    Overload that template in your child theme and then make your change.
    Since you are in the template, just make a call to a custom function – no need for a shortcode.


    Fábio Roque
    Participant

    @fabioroque92

    I don’t have another option to enable the shortcodes in activity posts ?

    I found this:

    Enable Shortcodes in Activity Screen of Buddypress

    but doesn’t work


    shanebp
    Moderator

    @shanebp

    That solution was for the old templates – 6 years ago!

    You could use this hook: do_action( 'bp_activity_entry_content' );
    Found in: buddypress\bp-templates\bp-nouveau\includes\activity\template-tags.php
    Again – no need to use a shortcode.


    Fábio Roque
    Participant

    @fabioroque92

    I think I wasn’t clear in what I’m looking for.

    I want to include a contactform7 shortcode in a activity feed


    shanebp
    Moderator

    @shanebp

    Then use the do_action hook to call a function that has a do_shortcode in it.
    Or put the shortcode call in the template.


    Fábio Roque
    Participant

    @fabioroque92

    Sorry mate but I can’t solved this problem.

    `
    function enable_shortcodes_in_feed()
    {

    add_filter( ‘ ??? ‘, ‘do_shortcode’, 1);

    }
    add_action( ‘bp_activity_entry_content’, enable_shortcodes_in_feed’ ); `

    And I tried add the do_shortcode in the template but doesn’t works too


    shanebp
    Moderator

    @shanebp

    That is not how shortcodes work.
    I suggest you read the WP docs re shortcodes.

    And maybe try the generator so you have an example.


    Fábio Roque
    Participant

    @fabioroque92

    I already have the shortcode created, but when I put the shortcode in activity feed he doesn’t work.

    I want to do this: https://buddypress.org/support/topic/enable-shortcodes-in-activity-screen-of-buddypress/ but in the new version of buddypress.


    shanebp
    Moderator

    @shanebp

    If you have the shortcode set up properly, you should be able to run it anywhere on the site.
    To confirm, try running it on a non-BP page.
    If it works there, it should work in the activity > entry template


    Fábio Roque
    Participant

    @fabioroque92

    if I go to the entry template and put <?php echo do_shortcode([shortcode)] ?> it Works, but if I insert a shortcode directly in the feed doesn’t work


    Fábio Roque
    Participant

    @fabioroque92

    Hi, I already found a solution.

    /**
     * Enable shortcode rendering in BuddyPress activity.
     */
    add_filter( 'bp_get_activity_content_body', function ( $content ) {
    
    	echo do_shortcode( $content );
    
    }, 0 );
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar