Skip to:
Content

Opened 3 years ago

Closed 3 years ago

#3858 closed defect (bug) (fixed)

When posting a new topic from forums directory, tags won't be added to topic

Reported by: deschle Owned by:
Milestone: 1.6 Priority: normal
Severity: normal Version: 1.5.1
Component: Forums Keywords:
Cc:

Description

Tags are added correctly when creating a new topic from a group page.

Change History (3)

comment:1 deschle3 years ago

As far is I can see, the user rights for adding tags is checked in bp-groups-filters.php:

function groups_filter_bbpress_caps( $value, $cap, $args ) {
	global $bp;

	if ( is_super_admin() )
		return true;

	if ( 'add_tag_to' == $cap )
		if ( $bp->groups->current_group->user_has_access ) return true;

	if ( 'manage_forums' == $cap && is_user_logged_in() )
		return true;

	return $value;
}

When creating a topic from a non group page, the $bp->groups->current_group->user_has_access is not initialized.

As a workaround I added the following code to my theme function.php:

function current_user_can_add_tag( $value, $cap, $args ) {
	global $bp;

	if ( 'add_tag_to' == $cap ) {
		$topic_id = $args[1];
		$topic = get_topic( $topic_id );
		if ( !$topic ) return false;	
		// is current user super admin or the topic poster?
                // maybe check if group admin?
		if ( is_super_admin() || $topic->topic_poster == $bp->loggedin_user->id )
			return true;	
	}	
	return $value;
}
add_filter( 'bb_current_user_can', 'current_user_can_add_tag', 10, 3 );

comment:2 boonebgorges3 years ago

  • Milestone changed from Awaiting Review to 1.6

Confirmed.

The problem is that we use groups_get_group() to populate the current_group property when a post is being created from the Forum directory, but groups_get_group() (BP_Groups_Group) doesn't have a user_has_access property. That seems like the right fix to me.

comment:3 boonebgorges3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5560]) Ensure that the BP_Groups_Group object has a user_has_access property set, to avoid errors when posting a forum topic from the Forum Directory. Fixes #3858

Note: See TracTickets for help on using tickets.