BuddyBoss Home – Web Support Forums Plugins BuddyBoss Wall Unable to delete other people's posts on my wall

Viewing 5 posts - 1 through 5 (of 5 total)
  • Question

    #34891
    @igrewupingmail

    If somebody post something on my wall I am unable to delete? I have the option to delete things that I have posted, but no option to delete anything posted by someone else on my wall.

    Answers

    #34895

    Alyssa
    Participant
    @alyssa-buddyboss

    @igrewupingmail that is correct, you are unable to delete posts by other people on your wall. This is on the to do list. Do you need to be able to delete individual comments, entire posts or both?

    #34897
    @igrewupingmail

    I would think both, user should have complete control over what is on their wall.

    #34903

    Alyssa
    Participant
    @alyssa-buddyboss

    @igrewupingmail I will add this to the developers to do list.

    #34904

    Alyssa
    Participant
    @alyssa-buddyboss

    @igrewupingmail all credit given to buddydev
    http://buddydev.com/buddypress/allow-activity-authors-delete-activity-comments-users-buddypress-based-social-network/
    for this code:

    add_filter( 'bp_activity_user_can_delete', 'buddydev_activity_user_can_delete', 10, 2 );
     
    function buddydev_activity_user_can_delete( $can_delete, $activity ) {
     
    //if the user already has permission
    //or the user is not logged in, we don't care
    if( $can_delete || ! is_user_logged_in() )
    return $can_delete ;
     
    //if we are here, let us check if the current user is the author of the parent activity
     
    $parent_activity = null;
    //if it is an activity comment
    if( $activity->item_id ) {
    $parent_activity = new BP_Activity_Activity( $activity->item_id );
    } else {
     
    $parent_activity = $activity;
    }
    //if the current user is author of main activity, he/she can delete it
    if( $parent_activity->user_id == get_current_user_id() )
    $can_delete = true;
    
    if( bp_loggedin_user_id() == bp_displayed_user_id() )
    $can_delete = true;
     
    return $can_delete;
    }
    
    //hook to ajax comment delete action
    add_action( 'wp_ajax_delete_activity_comment', 'buddydev_ajax_delete_activity_comment', 0 );
    //we have increased our priority to make sure that our handler gets called first
     
    function buddydev_ajax_delete_activity_comment() {
     
    // Bail if not a POST action
    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    return;
     
    // Check the nonce
    check_admin_referer( 'bp_activity_delete_link' );
     
    if ( ! is_user_logged_in() )
    exit( '-1' );
     
    $comment = new BP_Activity_Activity( $_POST['id'] );
     
    if ( ! bp_activity_user_can_delete( $comment ) )
    return false; //let others handle it
     
    // Call the action before the delete so plugins can still fetch information about it
    do_action( 'bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id );
     
    if ( ! bp_activity_delete_comment( $comment->item_id, $comment->id ) )
    exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>' );
     
    do_action( 'bp_activity_action_delete_activity', $_POST['id'], $comment->user_id );
    exit;
     
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • The question ‘Unable to delete other people's posts on my wall’ is closed to new replies.