What does your code look like thats adding the activity?
Thanks for the reply!
The code that enables the tracking is:
add_post_type_support( 'community-story', 'buddypress-activity' );
add_post_type_support( 'community-tip', 'buddypress-activity' );
in bp-custom.php
The code for rewriting the feed text is
bp_activity_new_post' => __( '%1$s shared a new <a href="%2$s">Story</a>', 'immersecommunity' ),
bp_activity_new_post_ms' => __( '%1$s posted a new <a href="%2$s">Story</a>, on the site %3$s', 'immersecommunity' ),
which is part of the register_post_type('community-story')
function (and mirrored in the 'community-tip'
post type.)
I’m not sure what %2$s
should be changed to
I just followed that link. and I have it working but the permalink is still the simple type, p=123
not the pretty type. which causes the link to break.
@thirty3, single activity links will look like, activity/p/123 but when you click on them they will redirect with member-specific activity link
That doesn’t seem to be the case. I wonder if it’s a bug since they are custom-post-types or if I just had some redundant code somewhere. I’ve got it working now though with a different method.
I’ll give another example, since this appears to me to be a bug.
Buddypress requires pretty permalinks, so why is my permalink a ?p=123
type??
Here’s the code I’m using to add a custom post type to my activity feed.
add_post_type_support( 'community-story', 'buddypress-activity' );
function customize_page_tracking_args() {
// Check if the Activity component is active before using it.
if ( ! bp_is_active( 'activity' ) ) {
return;
}
bp_activity_set_post_type_tracking_args( 'community-story', array(
'component_id' => 'activity',
'action_id' => 'new_community-story',
'bp_activity_admin_filter' => __( 'Shared a new story', 'buddypress' ),
'bp_activity_front_filter' => __( 'Community Story', 'buddypress' ),
'contexts' => array( 'activity', 'member' ),
'activity_comment' => true,
'bp_activity_new_post' => __( '%1$s shared a new <a href="%2$s">Community Story</a>', 'buddypress' ),
'bp_activity_new_post_ms' => __( '%1$s posted a new <a href="%2$s">Community Story</a>, on the site %3$s', 'buddypress' ),
'position' => 100,
) );
}
add_action( 'init', 'customize_page_tracking_args', 1000 );
function record_cpt_activity_content( $cpt ) {
if ( 'new_community-story' === $cpt['type'] ) {
$cpt['content'] = ' ';
}
return $cpt;
}
add_filter('bp_before_activity_add_parse_args', 'record_cpt_activity_content');
And here’s the result
<p>
<a href="https://domain.online/members/thirty3/">UserName/a> shared a new <a href="https://domain.online/?p=313">Community Story</a>
<a href="https://domain.online/?p=313" class="view activity-time-since bp-tooltip" data-bp-tooltip="View Discussion"><span class="time-since" data-livestamp="2018-04-23T20:07:18+0000">17 minutes ago</span></a>
</p>
@thirty3 https://domain.online/?p=313 is the default link for any post, and when someone clicks on it, it will be redirected according to your permalink setup.
You can find the same our default post as well.
OK thank you. Consider this resolved. I have a plugin that’s interfering with that redirect. The plugin is temporary and when I go live it wont be a problem. Thanks!