community

Filter Hook Users Since 3.8.0

Allows changing or hiding user display name and avatar.

The community filter combines the following related filters into one:

  • community_avatar
  • community_screenname
  • community_profile_preview_attributes

When using the common community filter name, each filter will also pass a $params['referer'] value to be able to identify which filter is being run.

Parameters

$output

(mixed) Varies based on filter `referer`

$params

(array) Includes `entry` key represent a listing, review, discussion, etc.

You need to have a working knowledge of Hooks before you get started.

Boilerplate Code

Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.

Clickfwd\Hook\Filter::add('community', function($output, $params) 
{
  // Uncomment line below to view available data passed into hook
  // For JReviews 3.x and earlier use dd instead of fwd_dd
  // fwd_dd($output, $params);
  
  return $output;
});
Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

Examples

Hide display name and avatar for specific users

function hide_user($output, $params)
{
	// List of user IDs for which to hide name and avatar
  	$hideUserIds = [10,20,30];

	if ( in_array($params['entry']['User']['user_id'], $hideUserIds)) 
	{
		return '';
	}

    return $output;
}

Clickfwd\Hook\Filter::add('community', 'hide_user', 20);

// The above filter combines the three filters below in one

// Clickfwd\Hook\Filter::add('community_avatar', 'hide_user', 20);

// Clickfwd\Hook\Filter::add('community_screenname', 'hide_user', 20);

// Clickfwd\Hook\Filter::add('community_profile_preview_attributes', 'hide_user', 20);

Source

  • /views/helpers/community.php