Skip to:
Content
Pages
Categories
Search
Top
Bottom

Group Admin cannot delete posts from the Activity Feed but WP Super Admin can

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello, I’ve just faced the problem you are talking about. Indeed, buddypress allows to delete activity entries only for superadmins or for activity “owners”.

    In order to fix this in your groups section go to file “wp-content/plugins/buddypress/bp-themes/bp-default/_inc/ajax.php”, locate function “bp_dtheme_delete_activity” (I have it on line 205). You should see the following access check there :

    `if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id )
    return false;
    `

    Replace this access check with custom one:

    `if( $activity->component == ‘groups’ && !class_exists(‘BP_Groups_Member’) )
    require( BP_PLUGIN_DIR . ‘/bp-groups/bp-groups-classes.php’ );
    if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id
    && !($activity->component == ‘groups’ && BP_Groups_Member::check_is_admin( $bp->loggedin_user->id, $activity->item_id ))
    )
    return false;
    `

    Not sure if that’s a best solution, though it does the trick.

    P.S. there is also “bp_activity_action_delete_activity” function in “wp-content/plugins/buddypress/bp-activity.php” with same access check, probably its worth to add custom access check there aswell, not sure, I’m good as it is at the moment.

    Thank you for your response, mrpavlikov, but unfortunately it doesn’t appear to have done the trick for me.

    After closer inspection of your code, is it possible that the check_is_admin() function should use the Group ID as the second variable instead of the Activity ID? And if so, how do I reference the Group ID?

    In case it makes a difference, I’m using a different theme than the bp-default theme that is contained within the plugins/buddypress directory, so I made the change that you suggested to the ajax.php file within both my child theme directory as well as within the plugins/buddypress/bp-themes/bp-default directory. I also made the change to buddypress/bp-activity.php, but it doesn’t seem to have done the trick.

    Thanks again for your assistance, and to anybody else who might have some insight on the issue.

    I’d also love to know if anybody can confirm that posts to the activity feed can only be deleted by the WordPress Super Admin and the person who posted the item but not by the Group Admin.

    That seems strange considering the “Delete” links appear next to the items when the Group Admin is viewing the feed. That link shouldn’t appear if the Group Admin shouldn’t have that ability.

    Hey,

    check_is_admin() is using Group ID as second variable, $activity->item_id IS actually Group ID if $activity->component is ‘groups’, its the way BuddyPress store activity in database.

    I’m using custom theme aswell, but I haven’t overrided ajax file.

    Could you try to switch back to default theme for a moment and check if you will be able to delete activity from groups?

    Also, to check if changes applied took place and are working you could add some echo before that access check in ajax files like

    `echo ‘AJAX WORKING’`

    and then use browser debug tool, for instance select “Inspect Element” in Chrome, select “Network” and after you press “Delete” link – there should be new request in “Network” to the file which actually is trying to delete activity. Select it and check repsonse body – if you see ‘AJAX WORKING’ there it will mean that the file you’ve modified is working.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Group Admin cannot delete posts from the Activity Feed but WP Super Admin can’ is closed to new replies.
Skip to toolbar