Another Custom Post Type in Activity Stream
-
Hello BP Members, I wish add another Custom Post Type in Activity Stream, is there a way?
-
`// Gravar Anuncio
add_filter ( ‘bp_blogs_record_post_post_types’, ‘activity_publish_custom_post_types’,1,1 );
function activity_publish_custom_post_types( $post_types ) {
$post_types[] = ‘user_images’;
return $post_types;
}add_filter(‘bp_blogs_activity_new_post_action’, ‘record_cpt_activity_action’, 1, 3);
function record_cpt_activity_action( $activity_action, $post, $post_permalink ) {
global $bp;
if( $post->post_type == ‘user_images’ ) {
if ( is_multisite() )
$activity_action = sprintf( __( ‘%1$s publicou um novo Anúncio: %2$s’, ‘buddypress’ ), bp_core_get_userlink( (int) $post->post_author ), ‘‘ . $post->post_title . ‘‘, ‘‘ . get_blog_option( $blog_id, ‘blogname’ ) . ‘‘ );else
$activity_action = sprintf( __( ‘%1$s publicou um novo Anúncio: %2$s’, ‘buddypress’ ), bp_core_get_userlink( (int) $post->post_author ), ‘‘ . $post->post_title . ‘‘ );}
return $activity_action;
}`This i use to record ONE activity, but HOW to register ANOTHER
Give this a try (not tested)
function activity_publish_custom_post_types( $post_types ) {
$post_types[] = ‘user_images’;
$post_types[]. = ‘my_other_CPT’;
return $post_types;I not try this but maybe work 🙂 thanks!
But I wish another custom … in your example: 2 custom post type to same activity :\
Thanks from Brazil
Hello BP team, I don´t found anything yet … anyone can help me?
I wish register antoher custom post type in activity stream
Thanks for all hard work BP <3
Hiya,
Does this code work?
I want to add ‘products’ CPT to activity stream…
Cheers,
Johnny
Will this work for all CPT posts WPMS network wide?
Cheers,
Johnny
This work with one cpt, i wish add another.
this code it´s okay.
modify “user_images” by your_custom_post
I just did something like this for cpt “business” and “event”, but removed mention of multisite:
// add custom post type business to the activity stream add_filter ( 'bp_blogs_record_post_post_types', 'activity_publish_custom_post_types',1,1 ); function activity_publish_custom_post_types( $post_types ) { $post_types[] = 'business'; $post_types[] = 'event'; return $post_types; } add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3); function record_cpt_activity_action( $activity_action, $post, $post_permalink ) { global $bp; if( $post->post_type == 'business' ) { $activity_action = sprintf( __( '%1$s created a new business listing, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' ); } if( $post->post_type == 'event' ) { $activity_action = sprintf( __( '%1$s created a new event, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' ); } return $activity_action; }
Nice!
@ewebber any demo site link?It’s on my live site, but as there have been no events or businesses listed since I put the code up, you won’t see much right now http://www.yeahhackney.com
The events that are currently there are not how it will show from now on.
@johnnymestizo you can see it on there now
@ewebber you put this code into what? bp-custom.php? and how are you posting with the custom post types? I mean how are they implemented when a user submits a post to your activity feed?
yes into bp-custom.php
I’m not clear what else you are asking, when a post of the types I have specified in my array is created it creates an item in the activity table.Sorry, got sidetracked… Go me! LoL
Anyway, the second part of my question was / is in reference too exactly what you just said… You’ve stated that ‘When a post of the types I have specified in my array is created’… My question is in reference to this statement. How are your users, on the Activity Feed, selecting to POST in the specified types? Dropdown? Radio button?
I’m curious because PHP happens on the Server Side prior to the page being sent to the user, as far as I know, so I’m not sure how your Activity Feed is, after the fact, telling BuddyPress’s Activity Feed that the user has SELECTED to Post an Event or a Business or whatever.
Users do not create posts from the activity stream, I’m not sure that this is possible.
Activity Updates. You know where they can post updates. You have three, the default, the events, and business. At least according to this code.
Your question was “How are your users, on the Activity Feed, selecting to POST in the specified types”. They cannot post from the activity stream.
I think the confusion here is you are questioning how users can create custom post types and that’s a different topic to this thread.
The default way would be from the admin dashboard. Other ways are possible depending on your own personal set up and what you want to do.
It’s okay. I looked at your site and sort of answered my question myself. You’re using Gravity Forms, that’s how you’re allowing your users to post via the custom post types. That’s all I wanted to know. Thanks for your help anyway. 🙂
I am using Gravity forms, but that’s only for standard posts not custom post types.
But I’ll leave you to work out the best ways to do what your site needs to do.
- The topic ‘Another Custom Post Type in Activity Stream’ is closed to new replies.