This topic has 3 replies, 2 voices, and was last updated 8 years by Radu.

  • Author
  • #143920
     Strothi
    Participant

    Hey guys,

    I’m making use of the portfolio option to show recordings of webinars that we do. I would like to have new webinars and any comment on a webinar item appear in the activity steam – which doesn’t happen at the moment – probably because it’s a custom post type. I’ve tried to include it myself using the code snippet below which I altered from the one I use to display jobs from my jobs plugin, but I guess I’m missing something, because it doesn’t work. I’m also not sure whether the actual custom post type is affected by how I call it, but I tested both “webinars” as well as “portfolio” and neither works. Any help would be appreciated. Here’s my code:

    function webinars_activity_args() {

    if ( ! bp_is_active( ‘activity’ ) ) {

    return;

    }

     

    add_post_type_support( ‘webinars’, ‘buddypress-activity’ );

     

    bp_activity_set_post_type_tracking_args( ‘webinars’, array(

    ‘component_id’             => ‘activity’,

    ‘action_id’                => ‘new_webinars’,

    ‘bp_activity_admin_filter’ => __( ‘Published a new Webinar’, ‘text-domain’ ),

    ‘bp_activity_front_filter’ => __( ‘Webinar’, ‘text-domain’ ),

    ‘contexts’                 => array( ‘activity’, ‘member’ ),

    ‘activity_comment’         => true,

    ‘bp_activity_new_post’     => __( ‘%1$s posted a new Webinar: <a href=”%2$s”>[Webinar]</a>’, ‘text-domain’ ),

    ‘bp_activity_new_post_ms’  => __( ‘%1$s posted a new Webinar: <a href=”%2$s”>[Webinar]</a>, on the site %3$s’, ‘text-domain’ ),

    ‘position’                 => 100,

    ) );

    }

    add_action( ‘init’, ‘webinars_activity_args’ );

     

     

    function webinars_include_post_type_title( $action, $activity ) {

    if ( empty( $activity->id ) ) {

    return $action;

    }

     

    if ( ‘new_webinars’ != $activity->type ) {

    return $action;

    }

     

    preg_match_all( ‘/<a.*?>([^>]*)<\/a>/’, $action, $matches );

     

    if ( empty( $matches[1][1] ) || ‘[Webinars]’ != $matches[1][1] ) {

    return $action;

    }

     

    $post_type_title = bp_activity_get_meta( $activity->id, ‘post_title’ );

     

    if ( empty( $post_type_title ) ) {

     

    switch_to_blog( $activity->item_id );

     

    $post_type_title = get_post_field( ‘post_title’, $activity->secondary_item_id );

     

    // We have a title save it in activity meta to avoid switching blogs too much

    if ( ! empty( $post_type_title ) ) {

    bp_activity_update_meta( $activity->id, ‘post_title’, $post_type_title );

    }

     

    restore_current_blog();

    }

     

    return str_replace( $matches[1][1], esc_html( $post_type_title ), $action );

    }

    add_filter( ‘bp_activity_custom_post_type_post_action’, ‘webinars_include_post_type_title’, 10, 2 );

     

    Also, if we’re at it: On the bottom of the single portfolio item the heading for the related portfolio items says: Related Projects. How do I change the title to “Other webinars”?

    Thanks so much in advance!

    #143931
     Radu
    Moderator

    Hi,

    For the moment we haven’t a plug and play code.

    To can take a look at your code please paste it to a pastebin.com and set php syntax highlite please.

    Meanwhile please take a look here : https://codex.buddypress.org/plugindev/post-types-activities/

    Let me know

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #143935
     Strothi
    Participant

    Hey Radu,

    please find the code on pastebin here: http://pastebin.com/FZti3pDU

    Thanks in advance for looking into it!

    Kind regards,
    Philip

    #144295
     Radu
    Moderator

    Hi, the code seems to be ok!
    IF that it’s not works please try again using the bp codes examples : https://codex.buddypress.org/plugindev/post-types-activities/

    Following this you should be able to achieve that

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?