Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • FTLRalph
    Participant

    @ftlralph

    Desperate bump


    FTLRalph
    Participant

    @ftlralph

    And like most cases I figured it out after posting the question

    public function should_send_mention_notificaton($value, $usernames, $user_id, $activity)
    {
    	// Return false if activity author is blocked by user_id
    	global $wpdb;
    	
    	$id_maybe_blocked = $activity->user_id;
    	$blocked_ids = $wpdb->get_col( "SELECT target_id FROM {$wpdb->base_prefix}bp_block_member WHERE user_id = '$user_id' ");
    	if (in_array($id_maybe_blocked, $blocked_ids) == true)
    		return false;
    	return true;
    }
    add_filter( 'bp_activity_at_name_do_notifications', 'should_send_mention_notificaton', 1, 4);

    FTLRalph
    Participant

    @ftlralph

    It does look like it’s a bp-legacy thing.

    I’m no JavaScript guy but in the js file included in default bp-legacy themes there appears to be this code which is the only place I can force it to cancel the form submission, but I’d need to detect something is wrong here in the JavaScript first.

    This is the relevant section of the buddypress-activity.js file:

    // Submitting comments and replies
    if ( 'ac_form_submit' === target.prop( 'name' ) ) {
    	var comment_content, comment_data;
    
    	form = target.closest( 'form' );
    	item_id = activity_id;
    
    	// Stop event propagation
    	event.preventDefault();
    
    	if ( target.closest( 'li' ).data( 'bp-activity-comment-id' ) ) {
    		item_id    = target.closest( 'li' ).data( 'bp-activity-comment-id' );
    	}
    
    	comment_content = $( form ).find( 'textarea' ).first();
    
    	target.addClass( 'loading' ).prop( 'disabled', true );
    	comment_content.addClass( 'loading' ).prop( 'disabled', true );
    
    	comment_data = {
    		action                        : 'new_activity_comment',
    		_wpnonce_new_activity_comment : $( '#_wpnonce_new_activity_comment' ).val(),
    		comment_id                    : item_id,
    		form_id                       : activity_id,
    		content                       : comment_content.val()
    	};
    
    	// Add the Akismet nonce if it exists
    	if ( $( '#_bp_as_nonce_' + activity_id ).val() ) {
    		comment_data['_bp_as_nonce_' + activity_id] = $( '#_bp_as_nonce_' + activity_id ).val();
    	}
    
    	parent.ajax( comment_data, 'activity' ).done( function( response ) {
    		target.removeClass( 'loading' );
    		comment_content.removeClass( 'loading' );
    		$( '.acomment-reply' ).attr( 'aria-expanded', 'false' );
    		// etc...

    FTLRalph
    Participant

    @ftlralph

    Bump – if anyone can assist, what hook should I look for to see how comments get pre-processed before submitting the form? In order to display a message that the content is inappropriate or something beforehand


    FTLRalph
    Participant

    @ftlralph

    I’m using 3.2.0 BP plugin with just a CSS-modified bp-default theme. It definitely fades out the comment and replaces it with basically a “nah son” message with no way to go back.

    k

    I don’t *think* the theme has anything to do with this, as it’s all form-related stuff that has its origins in the plugin files.

    Where would be the best place/function to look to see how comments get pre-processed before submitting the form?


    FTLRalph
    Participant

    @ftlralph

    Thanks

    But it might actually just be activity comments then, I hadn’t checked posts, but when leaving a comment the entire submission form goes away and the “You have posted an inappropriate word” message is shown in its place

    The type of behavior for posts you describe is essentially what I was looking to do with comments


    FTLRalph
    Participant

    @ftlralph

    Also for what it’s worth, what I’m doing here is catching image links prior to oembed so I can wrap them in <img /> tags (this way it works for all images, not just imgur and a select few)

    Plus oembed is ugly but I like it for Youtube links

    Is there an easier way to do this? Maybe just “don’t use oembed except for Youtube” type of hacking?


    FTLRalph
    Participant

    @ftlralph

    Thanks, yeah I’m going to look into some SQL action to get what I want, I think I’m just thinking about it wrong


    FTLRalph
    Participant

    @ftlralph

    True that’s what I’m thinking too I’m kinda just testing my luck here hacking away at a “recent activity” plugin for BP

    It uses this line to get recent activity from the DB

    $recent_blogs = $wpdb->get_results( "SELECT user_id, content, item_id, id, date_recorded FROM {$wpdb->prefix}bp_activity WHERE TYPE = 'activity_comment' ORDER BY date_recorded DESC LIMIT $number_blogs" );

    Of course it gives the SELECTed stuff: user_id, content, item_id, id, date_recorded
    However that user_idis that of this particular activity (a comment, perhaps) whereas I’d like also the user_idof the activity being commented on (if that’s the case).

    I guess I was just thinking there was a bp_get_activity($item_id)->author,content,date etc type of function

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