Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity for custom post types in MULTISITE


  • Amin
    Participant

    @aminima

    Hi there,

    I need to edit the activity custom post type elements based on each post type, in a multisite installation. for example for woocommerce products, I want this

    “THE USER” added the product “THE POST TITLE WITH PERMALINK” in “THE SUBSITE BLOGNAME”

    and for EDD products”

    “THE USER” added the download “THE POST TITLE WITH PERMALINK” in “THE SUBSITE BLOGNAME”

    I read lots of forums and answers, and finally got this:

    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;
    
    	$user_link = bp_core_get_userlink((int)$post->post_author);
    	$post_url = '<a href="' . $post_permalink . '">' . $post->post_title . '</a>';
    
    	if ( is_multisite() ) {
    
    		$blog_link =  '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ;
    
      		 if ($post->post_type == 'download') {
    			 $activity_action = sprintf(__('%1$s added the product %2$s in %3$s ', 'buddypress') , $user_link, $post_url), $blog_link ;
    		}
    
    		if ($post->post_type == 'product') {
    			 $activity_action = sprintf(__('%1$s added the download %2$s in %3$s ', 'buddypress') , $user_link, $post_url), $blog_link ;
    		}
    	}
       return $activity_action;
    }

    The problem is $blog_link. it does not return the subsite blog name and url, it allways return the main site blogname and url 🙁

    Thank you in advance

  • You must be logged in to reply to this topic.
Skip to toolbar