Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

  • etatus
    Participant

    @etatus

    And here it is another possible workaround:

    Solved – BuddyPress Smtp Settings


    etatus
    Participant

    @etatus

    Hi, I’m trying to get SMTP and Buddypress work together too and I find here the cause and a possible workaround. I didn’t test yet, so if you try first, please let us now if it works.

    https://wordpress.org/support/topic/using-an-smtp-plugin-2/


    etatus
    Participant

    @etatus

    I found a workaround to avoid the creation of duplicate activities for the same cpt post on updating.

    function me_activity_parse_args_filter( $args = array() ) {     
        if ( !empty( $args['type'] ) && $args['type'] == 'new_your-cpt' ) {
                    $activities = bp_activity_get(array(
                            'max' => 1,
                            'filter' => array(
                            'action' => 'new_your-cpt',
                            'secondary_id' =>  $args['secondary_item_id'],
                            ),
                    ) );
                    if (count($activities['activities'])==0) { // The cpt post doesn't have activity yet, so we set the group information
                            $args['component'] = 'groups'; // You could set this as 'component_id' in bp_activity_set_post_type_tracking_args
                            if ( !empty(bp_get_current_group_id()) ) $args['item_id'] = bp_get_current_group_id();
                            if (empty($args['content'])) $args['content'] = ' ';  // To make sure content filter applies afterwards 
                    } else { // Activity already exists
                            $args['type'] = false; // Delete duplicate activity
                    }
        }     
        return $args;
    }
    add_filter('bp_after_activity_add_parse_args', 'me_activity_parse_args_filter',10,1);

    etatus
    Participant

    @etatus

    Here is another approach. I dont like it at all because you cannot check a custom post type (you dont have the activity object). But it works.

    function me_filter_bp_activity_item_id_before_save( $item_id ) { 
        if ( !empty(bp_get_current_group_id()) ) $item_id = bp_get_current_group_id();
        return $item_id ; 
    }; 
             
    add_filter( 'bp_activity_item_id_before_save', 'me_filter_bp_activity_item_id_before_save', 10, 1 );

    BTW: The value 1 seems to be the default blog ID.

    In this thread @imath explains that:

    Custom Post Type Support for Activity


    etatus
    Participant

    @etatus

    I’m also interested in solving this problem (I think the number 1 is actually the user id). The only way I could find is to use bp_before_activity_add_parse_args filter:

    function me_activity_parse_filter( $cpt ) {
        if ( $cpt['type'] == 'your_custom_type' ) {
            $cpt['item_id'] = bp_get_current_group_id();
        }     
        return $cpt;
    }
    add_filter('bp_before_activity_add_parse_args', 'me_activity_parse_filter');

    However, if the cpt post is updated a new activity is created instead updating the original one…

    Note that in bp_activity_set_post_type_tracking_args I have
    'component_id' => 'groups',

    Maybe @imath can help us to solve this issue.

Viewing 5 replies - 1 through 5 (of 5 total)
Skip to toolbar