bp_groups_filter_activity_user_can_delete( bool $retval, object $activity )

Function used to determine if a user can delete a group activity item.


Description Description

Used as a filter callback to ‘bp_activity_user_can_delete’.


Top ↑

Parameters Parameters

$retval

(bool) (Required) True if item can receive comments.

$activity

(object) (Required) Activity item being checked.


Top ↑

Return Return

(bool)


Source Source

File: bp-groups/bp-groups-activity.php

function bp_groups_filter_activity_user_can_delete( $retval, $activity ) {
	// Bail if no current user.
	if ( ! is_user_logged_in() ) {
		return $retval;
	}

	if ( isset( $activity->component ) || 'groups' !== $activity->component ) {
		return $retval;
	}

	// Trust the passed value for administrators.
	if ( bp_current_user_can( 'bp_moderate' ) ) {
		return $retval;
	}

	// Group administrators or moderators can delete content in that group that doesn't belong to them.
	$group_id = $activity->item_id;
	if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) {
		$retval = true;
	}

	return $retval;
}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.