BuddyDev

Search

Buddypress Activity spam link

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #14506

    Hello Brajesh,

    I found the code to add mark as spam button to activities but I would like to know if you can re-edit it to perform the following functions.

    1. A activity update must be marked as spam 10 times by logged in users before it can be actually registered as an actual spam (logged in users determine the frequency at which an activity update can truly be regarded as spam)

    2. Ability to enable Admin and another chosen role to see and mark activities as spam (For example only the admin and authors or moderators can see the mark as spam link )

    This is the code I found on Gith hub but I dont think it works perfectly I had problems activating it.

     <?php
    /*
    Plugin Name: BuddyPress Activity Spam Link
    Description: Adds the "Mark as spammer" link back to the admin bar, and adds "Spammer" to the activity stream's entry meta buttons.
    Plugin URI: http://sillybean.net/
    Version: 0.2
    Author: Stephanie Leary
    */
    // restore action moved to settings in 1.6
    add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
    // Add Mark as Spammer link to the admin bar
    add_action( 'admin_bar_menu', 'mark_user_as_spammer' );
    function mark_user_as_spammer() {
    	global $wp_admin_bar, $bp;
    	
    	// Unique ID for the 'My Account' menu
    	$bp->user_admin_menu_id = 'user-admin';
    	
    	// User Admin > Spam/unspam	
    	if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : 
    		$wp_admin_bar->add_menu( array(
    			'parent' => $bp->user_admin_menu_id,
    			'id'     => $bp->user_admin_menu_id . 'mark-as-spammer',
    			'title'  => __( 'Mark as Spammer', 'buddypress' ),
    			'href'   => wp_nonce_url( bp_displayed_user_domain() . 'admin/mark-spammer/', 'mark-unmark-spammer' ),
    		) );
    	else :
    		$wp_admin_bar->add_menu( array(
    			'parent' => $bp->user_admin_menu_id,
    			'id'     => $bp->user_admin_menu_id . 'unmark-as-spammer',
    			'title'  => __( 'Not a Spammer', 'buddypress' ),
    			'href'   => wp_nonce_url( bp_displayed_user_domain() . 'admin/unmark-spammer/', 'mark-unmark-spammer' ),
    		) );	
    	endif;
    }
    // Add Spammer link button to activity stream
    add_action( 'bp_activity_entry_meta', 'mark_activity_user_as_spammer' );
     
    function mark_activity_user_as_spammer() {
    	if ( current_user_can( 'edit_users' ) ) {
    		$user_id = bp_get_activity_user_id();
    		
    		$href = wp_nonce_url( bp_get_activity_user_link() . 'admin/mark-spammer/', 'mark-unmark-spammer' );
    		$label = __( 'Spammer', 'buddypress' );
    			
    		echo '<a class="button" href="' . $href . '">' . $label . '</a>';
    	}
    } 
  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #14539

    Hi Tosin,
    I won’t be able to look into it and assist as we have a moderation plugin coming this week and I am investing my time on that. Once the plugin is available and you still feel you need to use this code, Please feel free to post back and I or one of our team members will help.

    At the moment, I am just trying to avoid any duplicate effort.

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved