Enable shortcode in BuddyPress activity feed
-
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
-
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.I don’t have another option to enable the shortcodes in activity posts ?
I found this:
but doesn’t work
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.I think I wasn’t clear in what I’m looking for.
I want to include a contactform7 shortcode in a activity feed
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.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
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.
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.
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 templateif 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
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 );
Hi Fabio,
I happened to come across your post and was trying to use it on buddyboss theme and plugin but not sure why nothing is happening.
I enabled your code in code snippet and i post a shortcode in activity feed, but nothing shows up…
Do you have any idea?
Thank you
Hi @futureyoon
Try this
/** * Render shortcodes on feed posts */ function enable_shortcode_bp_activity($content) { $content = stripslashes($content); return do_shortcode($content); } add_filter('bp_get_activity_content_body', 'enable_shortcode_bp_activity', 0);
ps: this was not tested in buddyboss 2.0
Thank you so much, Fabio.
Yes the code seems working.
I can see that it’s reacting as in I can see some shortcodes are showing up but not particularly for H5P shortcode.https://snipboard.io/kebxSK.jpg
I understand this might be beyond your knowledge, but do you happen to know how to enable the H5P shortcode in activity feed?
Appreciate that.
when I developed this, I had problems with css styles, js files… maybe is something like that, I don’t know, I never used the H5P.
I used this code to insert my own shortcodes!
I would like to help you, but without testing is difficult. Try search in H5P documentation!
I think I found the reason but not sure how to solve.
I added the shortcode in a page to see how H5P is working and found out that H5P is using ‘iframe’ method.https://snipboard.io/NCvBSL.jpg
but I beleive that buddyboss is not allowing the iframe on the activity feed (not sure, I might be wrong).
then do you have any idea how to enable the iframe feature on the activity feed?
so that possibly h5p shortcode is working.Please let me know your thought.
Thank you so much
@fabioroque92 Are you able to take this effort? I am OK to pay you for your expertise if you can help me get this work. Pleaes help.
- You must be logged in to reply to this topic.