@enriksen –
To ‘do’ shortcodes in different content areas, you will need to filter do_shortcode() into certain functions. See the WordPress codex for documentation on do_shortcode() https://codex.wordpress.org/Function_Reference/do_shortcode and add_filter: https://codex.wordpress.org/Function_Reference/add_filter
To add it to the activity stream, you’ll want to add
`add_filter(‘bp_get_activity_content_body’, ‘do_shortcode’); // Adds shortcodes to activity content.`
Xprofile is similar:
`add_filter(‘bp_get_the_profile_field_value’, ‘do_shortcode’); // Adds shortcodes to xprofile content.`
You can find a list of filters in BuddyPress in bp-{component}/bp-{component}-filters in the buddypress files.
eg: https://buddypress.trac.wordpress.org/browser/trunk/bp-xprofile/bp-xprofile-filters.php
Remember that this will allow all shortcodes to be used [which is why it’s not on by default], currently there is no way to pick and choose what shortcodes to allow short of using a plugin such as https://wordpress.org/extend/plugins/bbpress2-shortcode-whitelist/.
ChrisClayton, thanks.
Can you tell how to enable shortcodes on activity stream of profiles, groups etc.
Or, is there simple way to enable it everywhere?
Please someone help, I am stucked with this.
I want to add buddypress to my site, but cant make this work.
Tried many ways.
the filter I mentioned above
`
add_filter(‘bp_get_activity_content_body’, ‘do_shortcode’); // Adds shortcodes to activity content.
`
will add it to the content of all activity (including on the profile page and groups)
If you need to add it to activity actions as well, you can also use
`
add_filter(‘bp_get_activity_action’, ‘do_shortcode’); // Adds shortcodes to activity action.
`
On: domain.com/members/admin/activity/13/ = video works.
On: domain.com/activity = video is not shown, shortcode is not shown, there is nothing, shortcode is not showed as text or anything, shortcode doesnt exist.
I see only this: admin posted an update 1 day, 8 hours ago.
`
function youtube( $atts, $content = null ) {
return ”;
}
add_shortcode(“youtube”, “youtube”);
add_filter(‘bp_get_the_profile_field_value’, ‘do_shortcode’);
add_filter(‘bp_get_activity_content_body’, ‘do_shortcode’);
add_filter(‘bp_get_activity_action’, ‘do_shortcode’);
`
I use this, but nothing works on activity, shortcodes disappearing from there, just in full view of article it works.
My youtube function disappearing here as well as my shortcode from budypress on my site. lol
function youtube( $atts, $content = null ) {
return ‘div id=”youtube”iframe width=”200″ height=”200″ src=”http://youtube.com/embed/’.$content.'” frameborder=”0″ allowfullscreen /iframe/div’;
}
add_shortcode(“youtube”, “youtube”);
add_filter(‘bp_get_the_profile_field_value’, ‘do_shortcode’);
add_filter(‘bp_get_activity_content_body’, ‘do_shortcode’);
add_filter(‘bp_get_activity_action’, ‘do_shortcode’);
I assume the errors in your div html are because of the forum software and they are fixed in your code?
The only things I can think of are…
- it doesn’t like the iframe
- another filter is messing with it
I’ll have a closer look at it in an hour or two and play around with it and get back to you.
On a sidenote: BuddyPress provides something out of the box for what you require… if you paste in the url to the youtube video in the activity content – it should automatically embed it. Are you certain you require the shortcode?
On my hosting oembed is not working.
That is why I need shortcode.