JReviews:Developers Filters

From JReviews Documentation
Revision as of 10:29, 12 April 2020 by Jreviews (Talk | contribs) (Add Custom Field As Label)

Jump to: navigation, search

JReviews 3 comes with Filters that allow you to make certain types of customizations and extend the functionality of JReviews without having to modify core files.

This is a development feature. We provide some examples to get you started, but writing custom code for filters is outside the scope of support.

Contents


What is a Filter?

JReviews has many filter hooks strategically placed in the code at points where you may want to change or override the value of a variable at runtime.

Filters can modify data by binding a callback function to a filter hook. When the filter is executed, each callback function is run in order of priority, and can modify the filtered data by returning a new value.

For example, you can use a filter to:

  • Change the page title and metatags of different pages
  • Override the permissions of specific users or user groups for different events (creating listings, reviews, etc.)
  • Add or remove CSS and Scripts to and from the page.

When you update JReviews, the filters continue to work because unlike standard overrides which use copies of existing core files, the filters allow you to extend the functionality without modifying or overriding existing core files.

Defining a new Filter Hook

JReviews 3 already comes with many filter hooks and we'll add more over time. However, if you need to create a new filter that is not yet available you would use the following syntax:

$data = \Clickfwd\Hook\Filter::filter('example_filter_name', $data, ['foo'=>$bar]);

Where:

  • $data is the variable that can be modified by filter callback function
  • $params are other arguments that can be passed to the filter callback function to provide context and their values cannot be modified by the filter.

Using Filter Functions

The following example shows how a callback function is bound to a filter hook:

function example_filter_callback_function($data, $params = [])
{
   // Modify $data in some way and return it
   return $data;
}
 
Clickfwd\Hook\Filter::add('example_filter_name', 'example_filter_callback_function', $priority = 10);

The $data variable can be modified inside the callback function and must always be returned at the end of the function.

To create new filter functions that are not overwritten on upgrades, create a new file in overrides and place your filter functions there:

Joomla

/templates/jreviews_overrides/filters/filter_functions.php

WordPress

/jreviews_overrides/filters/filter_functions.php

You must add a couple of lines at the beginning of the file. Otherwise, it will be processed as regular text. So the first lines of the file will look like this:

<?php
defined('MVC_FRAMEWORK') or die;

Available Filters

Miscellaneous

Sign Up Modal Benefits Description

Description

The "signup_modal_benefits_desc" filter allows you to modify the description text to highlight the benefits of registering on the site in the Sign Up modal shown to guests when trying to access a member feature (favorites, claims, inquiries, follow, etc.)

Usage

When the "signup_modal_benefits_desc" filter is called, it is passed one arguments with the HTML string that's output by default.

Example

function signup_modal_benefits_desc($html)
{
	// This line below outputs the default HTML.
	// If you want to exclude that, just remove the echo line.
	echo $html;
	?>
	<ul>
		<li>Save favorites</li>
		<li>Send inquiries</li>
		<li>Follows and seach alerts</li>
	</ul>
	<?php
}
 
Clickfwd\Hook\Filter::add('signup_modal_benefits_desc', 'signup_modal_benefits_desc', 10);

Screen Name and Avatar Filters

Description

There are three community filters that can be used to modify the user information that is shown in listings, reviews, and comments. These are "community_screenname", community_avatar", and "community_profile_preview_attributes".

Usage

The "community_screenname" filter receives the HTML output for the user's name as the first parameter, and a second parameter with the entry array.

The "community_avatar" filter receives the HTML output for the user's avatar as the first parameter, and a second parameter with the entry array.

The "community_profile_preview_attributes" filter receives an array of attributes as the first parameter, and a second parameter with the entry array.

In all cases, the entry in the second parameter could be the listing, review, or discussion array, depending on the output where the filter is being applied.

The array of attributes for "community_profile_preview_attributes" are added to the HTML wrapper of the screen name and avatar. These are used to be able to generate a request to get the profile info that can be displayed in a preview dialog. At this time, these attributes are only relevant for the community integrations for EasySocial and UserProfiles Add-on.

Example

Hide user name and avatar for specific user IDs
function hide_user($output, $params)
{
	// Replace the ID comma list below with the IDs of users for which you'd like to hide the name and avatar.
	$hideUserIds = [31,33,37];
 
	if ( in_array($params['entry']['User']['user_id'], $hideUserIds)) 
	{
		return '';
	}
 
    return $output;
}
 
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);

Images

Enable Lazy Loading

Description

The "enable_image_lazyloading" filter gives you control over the image lazy loading feature in JReviews to control it globally.

Usage

When the "enable_image_lazyloading" filter is called, it is passed one boolean argument with the current state of lazy loading.

Examples

Disable lazy loading globally

The following example shows how to disable lazy loading globally on the site.

Clickfwd\Hook\Filter::add('enable_image_lazyloading', function() {
	return false;
}, 10);

Image Attributes Before Render

Description

The "image_attributes_before_render" filter allows you to modify the HTML attributes that are applied to the image tag before it's rendered. The first parameter is the array of image attributes and the second parameter includes context data that helps figure out where the image is being loaded.

Image HTML After Render

Description

The "image_html_after_render" filter runs after the attributes have been applied to the HTML img tag. The first parameter is the HTML code for the image, allowing you to prepend, append or perform string replacements on the HTML code. While the second parameter includes context data.

Privacy

Cookie Consent

Description

The "cookie_consent" filter is used to allow disabling certain features based on the presence of a specific cookie. At this time the filter can be used to disable the follwing features:

  • Loading of Google Maps API: When the cookie_consent filter returns false, the map features will be automatically disabled on the site.

Usage

When the "cookie_consent" filter is called, it is passed one arguments with the default value of true which means the features are enabled by default. To disable them the filter must return false.

Examples

Disable Features When Consent Is Not Granted in iReview Theme

In this example, when the users on your site agree to your cookie policy a cookie with a name of cookieconsent_dismissed is set and that is the name of the cookie the example looks for. You need to adjust the name of the cookie based on your own cookie implementation. If you don't know the name of the cookie set by the solution you use (different from the iReview Theme), then you need to ask the provider of the cookie consent solution or you can try using the browser developer tools to find out.

  • In Chrome, you can find the cookies listed under the dev tools Application panel. On the left sidebar, you will find Storage / Cookies and you can click on your domain name to find all cookies stored for it.
  • In Firefox, you can find the cookies listed under the dev tools Storage panel. On the left sidebar, you will find Cookies and you can click on your domain name to find all cookies stored for it.

If you are going to be using this filter with iReview, choose the version of the code below that corresponds with your iReview version. Don't use both filters together!

/**
 * For iReview Joomla <=3.6.2 & iReview WordPress <=1.4.1
 */
function disable_cookie_consent_features($consent)
{
   $cookieName = 'cookieconsent_dismissed';
 
   if ( !isset($_COOKIE[$cookieName]) )
   {
      $consent = false;
   }
 
   return $consent;
}
 
Clickfwd\Hook\Filter::add('cookie_consent', 'disable_cookie_consent_features', 10);
/**
 * For iReview Joomla >=3.7.2 & iReview WordPress >=1.5.1
 */
 
function disable_cookie_consent_features($consent)
{
   $cookieName = 'cookieconsent_status';
 
   if ( !isset($_COOKIE[$cookieName]) || ( isset($_COOKIE[$cookieName]) && $_COOKIE[$cookieName] !== 'dismiss' ) )
   {
      $consent = false;
   }
 
   return $consent;
}
 
Clickfwd\Hook\Filter::add('cookie_consent', 'disable_cookie_consent_features', 10);

Notifications

Listing Inquiry Email Payload

Description

The "modify_inquiry_sender_info" filter is used to filter the inquiry email payload before the email is sent.

Usage

When the "modify_inquiry_sender_info" filter is called, it is passed two arguments. The first argument is an associative array with the email payload ($to, $bcc, $fromEmail, $fromName, $subject, $body). The second argument is an associative array with context data for the $listing and $event that triggered the email. $event is an object that allows retrieving sender user ID and IP address information.

Examples

Modify sender name and email

By default when an inquiry email is sent, the sender name and e-mail address are populated with the information entered in the inquiry form. This allows the recipient of the inquiry to reply directly to the sender. However, in some cases, you may not want the recipient to reply directly to the sender and you can use this filter to modify the email values before it is sent.

The $payload array includes the following keys: "to", "bcc", "fromEmail","fromName", "subject", "body".

function modify_inquiry_sender_info($payload, $params)
{
   $listing = $params['listing'];
 
   $event = $params['event'];
 
   $extraFields = json_decode($event->get('extra_fields'),true);
 
   $payload['fromEmail'] = '[email protected]';
 
   $payload['fromName'] = 'John Smith';
 
   return $payload;
}
 
Clickfwd\Hook\Filter::add('listing_inquiry_email_payload', 'modify_inquiry_sender_info', 10);

Asset Manager

Asset Manager Stylesheets

Description

The "asset_manager_stylesheets" filter is used to filter the stylesheets loaded by JReviews and Add-ons.

Usage

When the "asset_manager_stylesheets" filter is called, it is passed an associative array containing the paths of the stylesheets that will be loaded on the page. The array contains keys for different namespaces used to load stylesheets so it's possible to control the order in which these are loaded. The namespaces are: addon, core, bottom, and top.

Examples

Unload jQuery UI Stylesheet

It is possible to stop specific stylesheets from loading if you want to use your own stylesheets or have already overwritten them in your site's stylesheet.

function remove_stylesheets($stylesheets)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($stylesheets);
  unset($stylesheets['core']['jquery_ui_theme/jquery-ui-1.9.2.custom.css']);
 
  return $stylesheets;
}
 
Clickfwd\Hook\Filter::add('asset_manager_stylesheets', 'remove_stylesheets', 10);

Asset Manager Scripts

Description

The "asset_manager_scripts" filter is used to filter the scripts loaded by JReviews and Add-ons.

Usage

When the "asset_manager_scripts" filter is called, it is passed an associative array containing the paths of the scripts that will be loaded on the page. The array contains keys for different namespaces used to load scripts so it's possible to control the order in which these are loaded. The namespaces are: addon, core, bottom, and top.

Examples

Unload bxSlider Script
function remove_scripts($scripts)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($scripts);
  unset($scripts['top']['bxslider-4/jquery.bxslider.min.js']);
 
  return $scripts;
}
 
Clickfwd\Hook\Filter::add('asset_manager_scripts', 'remove_scripts', 10);

Metatags

Page Title Tag

Description

The "page_title_metatag" filter is used to filter the page title tag.

Usage

When the "page_title_metatag" filter is called, it is passed two arguments. The first argument is the page title. The second argument is an associative array with context data.

function page_title_tag($title, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($title, $params); 
 
  return $title;
}
 
Clickfwd\Hook\Filter::add('page_title_metatag', 'page_title_tag', 10);

Examples

Prepend Listing Count To Category Page Title Tag

This example will prepend the total number of listings in a category page to the page title tag. You can modify the example to limit the filter functionality to specific category IDs or menu IDs using the $catId and $menuId variables.

function add_count_category_title($title, $params)
{
 
  // Uncomment line below to dump filter arguments to the screen
  // dd($title, $params);
 
  $categoryPage = S2Array::get($params,'route') == 'categories.category';
 
  $catId = S2Array::get($params,'vars.cat_id');
 
  $menuId = S2Array::get($params,'vars.params.Itemid');
 
  $count = S2Array::get($params,'pagination.total');
 
  if ( $categoryPage && $count )
  {
    $title = $count .' '.$title;
  }
 
  return $title;
}
 
Clickfwd\Hook\Filter::add('page_title_metatag', 'add_count_category_title', 10);

Page Robots Metatag

Description

The "page_robots_metatag" filter is used to filter the page robots metatag so you can change the indexing rules for specific pages.

Usage

When the "page_robots_metatag" filter is called, it is passed two arguments. The first argument is the current value of the robots metatag. The second argument is an associative array with context data.

function change_robots_metatag($robots, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($robots, $params); 
 
  return $robots;
}
 
Clickfwd\Hook\Filter::add('page_robots_metatag', 'change_robots_metatag', 10);

Page Keywords Metatag

Description

The "page_keywords_metatag" filter is used to filter the page keywords metatag.

Usage

When the "page_keywords_metatag" filter is called, it is passed two arguments. The first argument is the current value of the keywords metatag. The second argument is an associative array with context data.

function change_keywords_metatag($keywords, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($keywords, $params); 
 
  return $keywords;
}
 
Clickfwd\Hook\Filter::add('page_keywords_metatag', 'change_keywords_metatag', 10);

Page Description Metatag

Description

The "page_description_metatag" filter is used to filter the page description metatag.

Usage

When the "page_description_metatag" filter is called, it is passed two arguments. The first argument is the current value of the description metatag. The second argument is an associative array with context data.

function change_description_metatag($description, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($description, $params); 
 
  return $description;
}
 
Clickfwd\Hook\Filter::add('page_description_metatag', 'change_description_metatag', 10);

Page Canonical Metatag

Description

The "page_canonical_metatag" filter is used to filter the page canonical URL.

Usage

When the "page_canonical_metatag" filter is called, it is passed two arguments. The first argument is the current value of the canonical link URL. The second argument is an associative array with context data.

function change_canonical_metatag($url, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($url, $params); 
 
  return $url;
}
 
Clickfwd\Hook\Filter::add('page_canonical_metatag', 'change_canonical_metatag', 10);

Page Prev Metatag

Description

The "page_canonical_metatag" filter is used to filter the page prev metatag.

Usage

When the "page_canonical_metatag" filter is called, it is passed two arguments. The first argument is the current value of the prev link URL. The second argument is an associative array with context data.

function change_prev_metatag($url, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($url, $params); 
 
  return $url;
}
 
Clickfwd\Hook\Filter::add('page_prev_metatag', 'change_prev_metatag', 10);

Page Next Metatag

Description

The "page_next_metatag" filter is used to filter the page next metatag.

Usage

When the "page_next_metatag" filter is called, it is passed two arguments. The first argument is the current value of the next link URL. The second argument is an associative array with context data.

function change_next_metatag($url, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($url, $params); 
 
  return $url;
}
 
Clickfwd\Hook\Filter::add('page_next_metatag', 'change_next_metatag', 10);

Facebook Open Graph Metatags

Description

There's a couple of filters that can be used to modify the FB OG tags: `open_graph_tags_before_parse` and `open_graph_tags_after_parse`. The before parse filter receives an array with the tag property names (og:title, og:type, etc.) as keys and the tag content property as values (listing title, restaurant.restaurant). The after parse filter contains the same keys, but the values are already the HTML for the meta tag that will be added to the page.

Both filters receive a second parameter which includes the listing array.

If you want to use a custom field in one of the FB OG tags, you can use the before parse filter to add a new element to the array:

$tags['og:tag-name'] = 'jr_fieldname';

The field value will be automatically retrieved and added to the tag content property.

Usage

function open_graph_tags_before_parse($tags, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($tags, $params); 
 
  return $tags;
}
 
Clickfwd\Hook\Filter::add('open_graph_tags_after_parse', 'open_graph_tags_after_parse', 10);
function open_graph_tags_after_parse($tags, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($tags, $params); 
 
  return $tags;
}
 
Clickfwd\Hook\Filter::add('open_graph_tags_after_parse', 'open_graph_tags_after_parse', 10);

Twitter Card Metatags

Description

There's a couple of filters that can be used to modify the Twitter Card tags: `twitter_cards_before_parse` and `twitter_cards_after_parse`. The before parse filter receives an array with the tag property names (twitter:title, twitter:card, etc.) as keys and the tag content property as values (listing title, summary). The after parse filter contains the same keys, but the values are already the HTML for the meta tag that will be added to the page.

Both filters receive a second parameter which includes the listing array.

If you want to use a custom field in one of the Twitter Card tags, you can use the before parse filter to add a new element to the array:

$tags['twitter:creator'] = 'jr_fieldname';

The field value will be automatically retrieved and added to the tag content property.

Usage

function twitter_cards_before_parse($tags, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($tags, $params); 
 
  return $tags;
}
 
Clickfwd\Hook\Filter::add('twitter_cards_after_parse', 'twitter_cards_after_parse', 10);
function open_graph_tags_after_parse($tags, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($tags, $params); 
 
  return $tags;
}
 
Clickfwd\Hook\Filter::add('twitter_cards_after_parse', 'twitter_cards_after_parse', 10);

Listings

Listing Form Bottom

Description

The "listing_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "listing_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Listing Submit Validation

Description

The "listing_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "listing_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Examples

Set a minimum required length for the listing summary

You can use the same approach for the description by creating a new filter and using "fulltext" instead of "introtext". You can also modify the filter to set a limit to the maximum number of characters that can be entered in the summary by changing the condition from < 100 to >= 100 so anything above 100 characters results in a validation message.

function minimum_summary_length($validation, $params)
{
	$summary = S2Array::get($params,'data.Listing.introtext');
 
	$summary = strip_tags($summary);
 
	if ( mb_strlen($summary) < 100 )
	{
		$validation[] = 'The summary needs to be at least 100 characters';
	}
 
	return $validation;
}
 
Clickfwd\Hook\Filter::add('listing_submit_validation', 'minimum_summary_length', 10);

Listing Save Pre

Description

The "listing_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "listing_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

function listing_save_pre($data, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($data, $params);
 
  return $data;
}
 
Clickfwd\Hook\Filter::add('listing_save_pre', 'listing_save_pre', 10);

Examples

Calculate Years From Date

This example will takes the value from a date custom field, and calculates the number of years from that date until today. The value is stored in the database, so it doesn't dynamically change unless the listing is updated.

function calc_years_from_date($data, $params) 
{
    $dateField = 'jr_date';
 
    $yearsField = 'jr_years';
 
    if ( !empty($data['Field']['Listing'][$dateField]) )
    {
        $date = new DateTime($data['Field']['Listing'][$dateField]);
 
        $today = new DateTime();
 
        $diff = $today->diff($date);
 
        $data['Field']['Listing'][$yearsField] = $diff->y;
    }
 
    return $data;
}
 
Clickfwd\Hook\Filter::add('listing_save_pre', 'calc_years_from_date', 10);

Listing Status Labels

Description

The "listing_status_labels" filter is used to filter the listing status labels (i.e. Hot, New, Featured).

Usage

When the "listing_status_labels" filter is called, it is passed two arguments. The first argument is an array of labels, allowing removing or adding new labels . The second argument is an associative array with context data.

Examples

Add Custom Field As Label

This example will output the selected/entered text for a text, single select or radio button custom field named jr_status as a label. If you want to have a different color for each select/radio option, the value of the selection is already included in the label CSS class output. So you would need to add new CSS classes to your template CSS or custom_styles.css file in JReviews overrides. For example, if the status option values are "open" and "closed", then you can add these CSS classes and adjust the background colors to your liking.

.jrStatusLabel.open {
   background-color: #468847;
}
.jrStatusLabel.closed {
   background-color: #b94a48;
}
function status_field_label($labels, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($labels, $params);
 
    $listing = array_get($params,'listing');
 
    // Only works for text, single select and radio button custom fields
 
    $statusText = array_get($listing,'Field.pairs.jr_status.text.0');
 
    $statusValue = array_get($listing,'Field.pairs.jr_status.value.0');
 
    if ( $statusText )
    {
	    $label = [
	      'class'=>'jrStatusLabel '.$statusValue,
	      'text'=>$statusText
	    ];    	
    }
 
    // Add new label in the first position
    array_unshift($labels, $label);
 
    return $labels;
}
 
Clickfwd\Hook\Filter::add('listing_status_labels', 'status_field_label', 10);
Add Labels For Different Paid Plans
function paid_plan_labels($labels, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($labels, $params);
 
    $listing = array_get($params,'listing');
 
    $planIds = array_get($listing,'Paid.plan_ids',[]);
 
    $basicPlanId = 1;
    $premiumPlanId = 2;
 
    if ( in_array($basicPlanId, $planIds) )
    {
      $labels['basic'] = [
      'class'=>'jrStatusLabel jrPurple', // jrRed, jrOrange, jrBlue, jrGreen, jrBrown, jrPurple, jrBrown
      'text'=>'Basic Plan'
      ];
    }
 
    if ( in_array($premiumPlanId, $planIds) )
    {
      $labels['premium'] = [
      'class'=>'jrStatusLabel jrGreen', // jrRed, jrOrange, jrBlue, jrGreen, jrBrown, jrPurple, jrBrown
      'text'=>'Premium Plan'
      ];
    }
 
    return $labels;
}
 
Clickfwd\Hook\Filter::add('listing_status_labels', 'paid_plan_labels', 10);
Add Label With Listing Type Title
function listing_type_label($labels, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($labels, $params);
 
    $listing = array_get($params,'listing');
 
    $listingType = (S2App::make('listing_type'))->getById($listing['ListingType']['listing_type_id']);
 
    $label = [
      'class'=>'jrStatusLabel jrRed', // jrRed, jrOrange, jrBlue, jrGreen, jrBrown, jrPurple, jrBrown
      'text'=>$listingType['ListingType']['title']
    ];
 
    // Add new label in the first position
    array_unshift($labels, $label);
 
    return $labels;
}
 
Clickfwd\Hook\Filter::add('listing_status_labels', 'listing_type_label', 10);

Reviews

Review Form Bottom

Description

The "review_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "review_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Review Submit Validation

Description

The "review_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "review_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Examples

Set a minimum required length for the review comments
function minimum_comment_length($validation, $params)
{
	$comment = S2Array::get($params,'data.Review.comments');
 
	$comment = strip_tags($comment);
 
	if ( mb_strlen($comment) < 100 )
	{
		$validation[] = 'The review comment needs to be at least 100 characters';
	}
 
	return $validation;
}
 
Clickfwd\Hook\Filter::add('review_submit_validation', 'minimum_comment_length', 10);

Review Save Pre

Description

The "review_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "review_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Review Form Rating Options

Description

The "review_form_rating_options" filter is used to filter the rating criteria options used in the review form.

Usage

When the "review_form_rating_options" filter is called, it is passed two arguments. The first argument is an array of the review options. The second argument is an associative array with context data.

Examples

Replacing the rating numbers with text in the review form

In the example below the rating scale is 5 and users are allow to not vote on rating criteria

function review_form_rating_options($options, $params)
{
	// Uncomment line below to dump filter arguments to the screen
	// dd($options, $params);
 
	$criteriaId = S2Array::get($params,'criteria_id');
 
	$listingTypeId = S2Array::get($params,'listing_type_id');
 
	$reviewType = S2Array::get($params,'review_type');
 
	$required = S2Array::get($params,'required');
 
	$scale = S2Array::get($params,'scale');
 
	$increment = S2Array::get($params,'increment');
 
	$options = [];
 
	if ( !$required )
	{
		$options['na'] = 'N/A';
	}
 
	$options[1] = 'Terrible';
	$options[2] = 'Not so bad';
	$options[3] = 'Just ok';
	$options[4] = 'Good';
	$options[5] = 'Excellent';
 
	return $options;
}
 
Clickfwd\Hook\Filter::add('review_form_rating_options', 'review_form_rating_options', 10);

Review Votes

Review Vote Save Pre

Description

The "review_vote_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "review_vote_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Review Discussions

Discussion Form Bottom

Description

The "discussion_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "discussion_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Discussion Submit Validation

Description

The "discussion_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "discussion_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Discussion Save Pre

Description

The "discussion_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "discussion_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Review Owner Replies

Owner Reply Form Bottom

Description

The "owner_reply_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "owner_reply_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Owner Reply Submit Validation

Description

The "owner_reply_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "owner_reply_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Owner Reply Save Pre

Description

The "owner_reply_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "owner_reply_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Reports

Report Form Bottom

Description

The "report_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "report_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Report Submit Validation

Description

The "report_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "report_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Report Save Pre

Description

The "report_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "report_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Listing Inquiries

Inquiry Form Bottom

Description

The "inquiry_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "inquiry_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Inquiry Submit Validation

Description

The "inquiry_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "inquiry_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Inquiry Save Pre

Description

The "inquiry_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "inquiry_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Listing Claims

Claim Form Bottom

Description

The "claim_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "claim_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Claim Submit Validation

Description

The "claim_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "claim_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Claim Save Pre

Description

The "claim_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "claim_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Media

Media Save Pre

Description

The "media_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "media_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Examples

Set cover as default for first photo upload
function media_use_cover_as_default($media, $params)
{
	if ( $params['is_new'] && $media['Media']['main_media'] == 1 )
	{
		$media['Media']['media_function'] = 'cover';
	}
 
	return $media;
}
 
Clickfwd\Hook\Filter::add('media_save_pre', 'media_use_cover_as_default', 10);
Set logo as default for first photo upload
function media_use_logo_as_default($media, $params)
{
	if ( $params['is_new'] && $media['Media']['main_media'] == 1 )
	{
		$media['Media']['media_function'] = 'logo';
	}
 
	return $media;
}
 
Clickfwd\Hook\Filter::add('media_save_pre', 'media_use_logo_as_default', 10);

Media Likes

Media Like Save Pre

Description

The "media_like_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "media_like_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Listings List

List Page LD JSON Structured Data

Description

The "list_page_ld_json_structured_data" filter is used to filter the structured data markup that will appear in list pages where all listings share the same listing type.

Usage

When the "list_page_ld_json_structured_data" filter is called, it is passed two arguments. The first argument is an array with the structured data before it's converted to JSON format . The second argument is an associative array with context data.

Listing List Action Buttons

Description

The "listing_list_action_buttons" filter is used to filter the action buttons for a listing in the list page.

Usage

When the "listing_list_action_buttons" filter is called, it is passed two arguments. The first argument is an associative array of button positions, allowing adding new buttons . The second argument is an associative array with context data.

Examples

Add button that links to external website

This example uses the URL stored in a custom field to create a link styled as a button that links to the website URL. You'll need to replace the field name "jr_website" with your actual field name and make any other changes needed to the button HTML format.

function add_website_button($buttons, $params)
{
	$listing = $params['listing'];
 
 	$CustomFields = ClassRegistry::getClass('CustomFieldsHelper','jreviews');
 
 	$url = $CustomFields->field('jr_website',$listing,false,false);
 
 	if ( $url )
 	{
		$newButton = sprintf('<a href="%s" class="jrButton jrBlue jrSmall">Visit website</a>',$url);
 
		$buttons[] = $newButton;
 	}
 
	return $buttons;
}
 
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'add_website_button', 10);
Remove compare button from list pages

This example hides the compare button in listing list pages only.

function remove_compare_button($buttons, $params) 
{
   unset($buttons['compare']);
}
 
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'remove_compare_button', 10);
Add inquiry button to listing list pages
function add_inquiry_button_list_page($buttons, $params)
{
   $listing = $params['listing'];
 
   $listingHelper = ClassRegistry::getClass('ListingHelperHelper');
 
   ob_start();
 
   $listingHelper->inquiry($listing);
 
   $inquiryButton = ob_get_clean();
 
   return $buttons;
}
 
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'add_inquiry_button_list_page', 10);
Add favorite button to listing list pages
function add_favorite_button_list_page($buttons, $params)
{
   $listing = $params['listing'];
 
   $listingHelper = ClassRegistry::getClass('ListingHelperHelper');
 
   ob_start();
 
   $listingHelper->favorite($listing);
 
   $favoriteButton = ob_get_clean();
 
   $buttons['favorite'] = $favoriteButton;
 
   return $buttons;
}
 
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'add_favorite_button_list_page', 10);

Listing List Action Button Extras

Description

The "listing_list_action_buttons_extras" filter is used to filter the action buttons for a listing in the list page. The extras button are processed before the rest of the buttons and are sometimes used to insert add-on buttons.

Usage

When the "listing_list_action_buttons_extras" filter is called, it is passed two arguments. The first argument is an associative array of button positions, allowing adding new buttons . The second argument is an associative array with context data.

Pre Get Listings Listpage Query

Description

The "pre_get_listings_listpage_query" filter is used to filter listings list database queries. Modifying the default database queries can lead to decreased performance because custom queries have not been optimized.

Usage

When the "pre_get_listings_listpage_query" filter is called, it is passed two arguments. The first argument is the ListingsRepository. The second argument is an associative array with context data.

Examples

Change Featured Listing Ordering With Most Recent Listings As Secondary Ordering

JReviews uses the listing ID as secondary ordering by default because it can be found in the same database table as the featured status. This example changes that to use the real creation date which can lead to decreased performance because it uses an ORDER BY statement with cross-table columns. This will become more noticeable in sites with a large number of listings.

<?php
defined('MVC_FRAMEWORK') or die;
 
function featured_created_ordering($ListingsRepository, $params)
{
  	// Uncomment line below to dump filter arguments to the screen
  	// dd($ListingsRepository, $params);
 
	$model = $ListingsRepository->getModel();
 
	if ( isset($model->order['featured']) )
	{
	  	$model->order['featured'] = 'Field.featured DESC, Listing.'.EverywhereComContentModel::_LISTING_CREATE_DATE.' DESC';
	}
 
  	return $ListingsRepository;
}
 
Clickfwd\Hook\Filter::add('pre_get_listings_listpage_query', 'featured_created_ordering', 10);
Change Featured Listing Ordering With Most Recent Paid Orders First

This example can lead to decreased performance because it uses an ORDER BY statement with cross-table columns. This will become more noticeable in sites with a large number of listings.

function featured_most_recent_transactions_ordering($ListingsRepository, $params)
{
  	// Uncomment line below to dump filter arguments to the screen
  	// dd($ListingsRepository, $params);
 
        $model = $ListingsRepository->getModel();
 
	if ( isset($model->order['featured']) )
	{
	  	$ListingsRepository->joins('LEFT JOIN #__jreviews_paid_orders AS PaidOrder ON Listing.'.$model::_LISTING_ID.' = PaidOrder.listing_id AND PaidOrder.order_amount > 0 AND order_active = 1');
 
	  	$model->order['featured'] = 'Field.featured DESC, PaidOrder.order_created DESC';
 
      	  	$ListingsRepository->group('Field.contentid');
	}
 
  	return $ListingsRepository;
}
 
Clickfwd\Hook\Filter::add('pre_get_listings_listpage_query', 'featured_most_recent_transactions_ordering', 10);
 
function featured_most_recent_transactions_ordering_count($ListingsRepository, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($ListingsRepository, $params);
 
    $model = $ListingsRepository->getModel();
 
    if ( isset($model->order['featured']) )
    {
        $ListingsRepository->countColumn('DISTINCT Field.contentid')->group('', true);
    }
 
    return $ListingsRepository;
}
 
Clickfwd\Hook\Filter::add('pre_get_listings_listpage_query_count', 'featured_most_recent_transactions_ordering_count', 10);

Pre Get Listings Listpage Query Count

Description

The "pre_get_listings_listpage_query_count" filter is used to filter the "count" query for listing list pages. Modifying the default database queries can lead to decreased performance because custom queries have not been optimized.

Usage

When the "pre_get_listings_listpage_query_count" filter is called, it is passed two arguments. The first argument is the ListingsRepository. The second argument is an associative array with context data.

Examples

View the above example where this filter is used together with the "featured_most_recent_transactions_ordering" filter.

Pre Get Listings Listings Module Query

Description

The "pre_get_listings_listings_module_query" filter is used to filter listings list database queries. Modifying the default database queries can lead to decreased performance because custom queries have not been optimized.

Usage

When the "pre_get_listings_listings_module_query" filter is called, it is passed two arguments. The first argument is the listing model. The second argument is an associative array with context data.


Post Get Listings Listpage Query

Description

The "post_get_listings_listpage_query" filter is used to filter the listings array before it is made available to the theme file.

Usage

When the "post_get_listings_listpage_query" filter is called, it is passed two arguments. The first argument is the listings array. The second argument is an associative array with context data.


Post Get Listings Listings Module Query

Description

The "post_get_listings_listings_module_query" filter is used to filter the listings array before it is made available to the theme file.

Usage

When the "post_get_listings_listings_module_query" filter is called, it is passed two arguments. The first argument is the listings array. The second argument is an associative array with context data.

Examples

Replace Listing Summary with Description in List Page
function list_page_replace_summary($listings, $params)
{
	foreach ($listings as & $listing)
	{
		if ( !$listing['Listing']['summary'] && $listing['Listing']['description'] )
		{
			$listing['Listing']['summary'] = $listing['Listing']['description'];
		}
	}
 
	return $listings;
}
 
Clickfwd\Hook\Filter::add('post_get_listings_listpage_query', 'list_page_replace_summary', 10);

Listing Detail

Listing Detail Action Buttons

Description

The "listing_detail_action_buttons" filter is used to filter the action buttons in the detail page.

Usage

When the "listing_detail_action_buttons" filter is called, it is passed two arguments. The first argument is an associative array of button positions, allowing adding new buttons . The second argument is an associative array with context data.

You can insert buttons in positions 1 through 9.

Examples

Add EasySocial Message Button
function add_easysocial_message_button($buttons, $params)
{
	if ( !defined('ES_MESSAGE_FILTER') )
	{
	   require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php');
 
	   ES::initialize();
 
	   ES::language()->loadSite();
 
	   define('ES_MESSAGE_FILTER', 1);
	}
 
	$listing = $params['listing'];
 
	$easysocial = '
	   <button type="button" class="jrButton jrSmall"
		data-es-conversations-compose=""
		data-id="'.$listing['User']['user_id'].'"
		data-es-provide="tooltip" 
		data-original-title="Contact This Member"
	   >
		<span class="jrIconMessage"></span> Contact This Member
	   </button>
	';
 
	$buttons[] = $easysocial;
 
	return $buttons;
}
 
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', 'add_easysocial_message_button', 10);

Listing Detail Action Button Extras

Description

The "listing_detail_action_buttons_extras" filter is used to filter the action buttons in the detail page. The extras button are processed before the rest of the buttons and are sometimes used to insert add-on buttons.

Usage

When the "listing_detail_action_buttons_extras" filter is called, it is passed two arguments. The first argument is an associative array of button positions, allowing adding new buttons . The second argument is an associative array with context data.

Post Get Listing Detailpage Query

Description

The "post_get_listing_detailpage_query" filter is used to filter the listing array before it is made available to the theme file.

Usage

When the "post_get_listing_detailpage_query" filter is called, it is passed two arguments. The first argument is the listing array. The second argument is an associative array with context data.

Examples

Strip Links From Listing Text

This example will replace link tags in the listing summary and description fields, leaving only the anchor text.

function strip_links_detail($listing, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($listing, $params);
 
    $listing['Listing']['text'] = preg_replace('#<a.*?>(.*?)</a>#i', '\1', $listing['Listing']['text']);
 
    return $listing;
}
 
Clickfwd\Hook\Filter::add('post_get_listing_detailpage_query', 'strip_links_detail', 10);

Listing Permissions

Trusted On Listing Create

Description

The "trusted_on_create_listing" filter is used to filter the moderation setting when a new listing is created.

Usage

When the "trusted_on_create_listing" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create listings without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Listing Submissions From Users With Published Listings
function trust_published_authors($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM %s WHERE %s = %d AND state = 1', EverywhereComContentModel::_LISTING_TABLE, EverywhereComContentModel::_LISTING_USER_ID, $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
      return true;
    }
  }
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_listing', 'trust_published_authors', 10);

Listing Allows Claims

Description

The "listing_allows_claims" filter is used to filter the listing claims configuration setting.

Usage

When the "listing_allows_claims" filter is called, it is passed two arguments. The first argument is the current value for listing claims. The second argument is an associative array with context data. The "Claim" button only appears on the listing if the filter returns true and the listing is not alredy claimed.

Examples

Enable Claims Only For Listings with Premium Paid Plans (PaidListings)
function claims_for_premium_listings($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $listing = $params['listing'];
 
  $premiumPlanIds = [1,2,3];
 
  $allow = isset($listing['Paid']) && array_intersect($premiumPlanIds, $listing['Paid']['plan_ids']);
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_claims', 'claims_for_premium_listings', 10);

Listing Allows Inquiries

Description

The "listing_allows_inquiries" filter is used to filter the listing inquiry configuration setting.

Usage

When the "listing_allows_inquiries" filter is called, it is passed two arguments. The first argument is the current value for listing inquiries. The second argument is an associative array with context data. The "Send Inquiry" button only appears on the listing if the filter returns true.

Examples

Enable Inquiries Only For Logged in Users
function inquiries_for_members($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $auth = S2Object::make('auth');
 
  return $auth->connected;
}
 
Clickfwd\Hook\Filter::add('listing_allows_inquiries', 'inquiries_for_members', 10);
Enable Inquiries Only For Claimed Listings
function inquiries_for_claimed_listings($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $listing = $params['listing'];
 
  $allow = S2Array::get($listing,'Claim.approved');
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_inquiries', 'inquiries_for_claimed_listings', 10);
Enable Inquiries Only For Listings with Premium Paid Plans (PaidListings)
function inquiries_for_premium_listings($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $listing = $params['listing'];
 
  $premiumPlanIds = [1,2,3];
 
  $allow = isset($listing['Paid']) && array_intersect($premiumPlanIds, $listing['Paid']['plan_ids']);
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_inquiries', 'inquiries_for_premium_listings', 10);

Listing Allows Favorites

Description

The "listing_allows_favorites" filter is used to filter the listing favorites configuration setting.

Usage

When the "listing_allows_favorites" filter is called, it is passed two arguments. The first argument is the current value for listing favorites. The second argument is an associative array with context data. The "Favorite" button only appears on the listing if the filter returns true.

Examples

Enable Favorites Only For Listings with Premium Paid Plans (PaidListings)
function favorites_for_premium_listings($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $listing = $params['listing'];
 
  $premiumPlanIds = [1,2,3];
 
  $allow = isset($listing['Paid']) && array_intersect($premiumPlanIds, $listing['Paid']['plan_ids']);
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_favorites', 'favorites_for_premium_listings', 10);
Add The Favorites Button to Listing List Pages
function add_favorite_button_list_page($buttons, $params)
{
   $listing = $params['listing'];
 
   $listingHelper = ClassRegistry::getClass('ListingHelperHelper');
 
   ob_start();
 
   $listingHelper->favorite($listing);
 
   $favoriteButton = ob_get_clean();
 
   $buttons['favorite'] = $favoriteButton;
 
   return $buttons;
}
 
Clickfwd\Hook\Filter::add('listing_list_action_buttons', 'add_favorite_button_list_page', 10);

Listing Allows User Reviews

Description

The "listing_allows_user_reviews" filter is used to filter filter the listing user reviews setting.

Usage

When the "listing_allows_user_reviews" filter is called, it is passed two arguments. The first argument is the current value for the allow user reviews setting. The second argument is an associative array with context data. User reviews are only enabled for a listing if the callback function returns true.

function allow_user_reviews($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_user_reviews', 'allow_user_reviews', 10);

Listing Allows Editor Reviews

Description

The "listing_allows_editor_reviews" filter is used to filter filter the listing editor reviews setting.

Usage

When the "listing_allows_editor_reviews" filter is called, it is passed two arguments. The first argument is the current value for the allow editor reviews setting. The second argument is an associative array with context data. Editor reviews are only enabled for a listing if the callback function returns true.

function listing_allows_editor_reviews($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_allows_editor_reviews', 'allow_editor_reviews', 10);

Listing User Reviews Open

Description

The "listing_user_reviews_open" filter is used to filter the open/closed state for user reviews in a listing.

Usage

When the "listing_user_reviews_open" filter is called, it is passed two arguments. The first argument is the current value for the open/closed state. The second argument is an associative array with context data. When the filter returns true the reviews are open, otherwise listing no longer accepts reviews, but displays existing reviews and rating information.

Examples

Control user reviews open state using a listing custom field

This example lets you add the ability to close user reviews for a specific listing. It uses a listing custom field to let you set the open state for user reviews. You can set this field for admin access only or if you prefer you can also allow listing owners to have control of this feature when they edit the listings.

function user_reviews_open($open, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($state, $params);
 
  $listing = $params['listing'];
 
  // jr_userreviewstate is a radio field with yes/no option values. You could also use a checkbox custom field if you prefer
  // and modify the example accordingly. In this example, when a value is not found for the custom field the reviews will be open.
  $fieldName = 'jr_userreviewsstate';
 
  if ( isset($listing['Field']['pairs'][$fieldName]) && $listing['Field']['pairs'][$fieldName]['value'][0] == 'no' )
  {
    return false;
  }
 
  return $open;
}
 
Clickfwd\Hook\Filter::add('listing_user_reviews_open', 'user_reviews_open', 10);

Listing Editor Reviews Open

Description

The "listing_user_reviews_open" filter is used to filter the open/closed state for user reviews in a listing.

Usage

When the "listing_user_reviews_open" filter is called, it is passed two arguments. The first argument is the current value for the open/closed state. The second argument is an associative array with context data. When the filter returns true the reviews are open, otherwise listing no longer accepts reviews, but displays existing reviews and rating information.

function editor_reviews_open($open, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($open, $params);
 
  return $open;
}
 
Clickfwd\Hook\Filter::add('listing_editor_reviews_open', 'editor_reviews_open', 10);

Can Create Listing

Description

The "can_create_listing" filter is used to filter the user permission to create a new listing.

Usage

When the "can_create_listing" filter is called, it is passed two arguments. The first argument is the current value for the create permission. The second argument is an associative array with context data.

Examples

Limit listing submissions to one per user

This example limits the listing submissions to one per user and allows you to override the access denied message shown to the user.

function one_listing_limit_registered_user($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  $listingPermissions = (S2Object::make('perm'))->__('listing');
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM %s WHERE %s = %d AND state = 1', EverywhereComContentModel::_LISTING_TABLE, EverywhereComContentModel::_LISTING_USER_ID, $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
      $listingPermissions->setMessage('Sorry, you already created a listing and there\'s a limit of one listing per user');
 
      return false;
    }
  }
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_create_listing', 'one_listing_limit_registered_user', 10);

Can Update Listing

Description

The "can_update_listing" filter is used to filter the user permission to update a listing.

Usage

When the "can_update_listing" filter is called, it is passed two arguments. The first argument is the current value for the update permission. The second argument is an associative array with context data.

function can_update_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_update_listing', 'can_update_listing', 10);

Can Add Listing Metadata

Description

The "can_add_listing_metadata" filter is used to filter the user permission to add meta description and keywords while creating or updating a listing.

Usage

When the "can_add_listing_metadata" filter is called, it is passed two arguments. The first argument is the current value for the metadata permission. The second argument is an associative array with context data.

function can_add_listing_metadata($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_add_listing_metadata', 'can_add_listing_metadata', 10);

Can User WYSIWYG Editor in Listing

Description

The "can_use_editor_in_listing" filter is used to filter the user permission to use the WYSIWYG editor for listing summary and description fields.

Usage

When the "can_use_editor_in_listing" filter is called, it is passed two arguments. The first argument is the current value for the WYSIWYG Editor permission. The second argument is an associative array with context data.

function can_use_editor_in_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_use_editor_in_listing', 'can_use_editor_in_listing', 10);

Can Publish Listing

Description

The "can_publish_listing" filter is used to filter the user permission to publish a listing.

Usage

When the "can_publish_listing" filter is called, it is passed two arguments. The first argument is the current value for the publish permission. The second argument is an associative array with context data.

function can_publish_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_publish_listing', 'can_publish_listing', 10);

Can Delete Listing

Description

The "can_delete_listing" filter is used to filter the user permission to delete a listing.

Usage

When the "can_delete_listing" filter is called, it is passed two arguments. The first argument is the current value for the delete permission. The second argument is an associative array with context data.

function can_delete_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_delete_listing', 'can_publish_listing', 10);

Can Claim Listing

Description

The "can_claim_listing" filter is used to filter the user permission to claim a listing.

Usage

When the "can_claim_listing" filter is called, it is passed two arguments. The first argument is the current value for the claim permission. The second argument is an associative array with context data.

function can_claim_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_claim_listing', 'can_claim_listing', 10);

Can Send Listing Inquiry

Description

The "can_send_listing_inquiry" filter is used to filter the user permission to send a listing inquiry.

Usage

When the "can_send_listing_inquiry" filter is called, it is passed two arguments. The first argument is the current value for the send inquiry permission. The second argument is an associative array with context data.

Examples

Prevent Guests from sending inquiries
function prevent_guest_inquiries($permission, $params = [])
{
  $auth = S2Object::make('auth');
 
  if ( $auth->id == 0 )
  {
    return false;
  }
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_send_listing_inquiry', 'prevent_guest_inquiries', 10);

Can Favorite Listing

Description

The "can_favorite_listing" filter is used to filter the user permission use the favorites feature.

Usage

When the "can_favorite_listing" filter is called, it is passed two arguments. The first argument is the current value for the favorites permission. The second argument is an associative array with context data.

function can_favorite_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_favorite_listing', 'can_favorite_listing', 10);

Can Feature Listing

Description

The "can_feature_listing" filter is used to filter the user permission use feature a listing.

Usage

When the "can_feature_listing" filter is called, it is passed two arguments. The first argument is the current value for the feature permission. The second argument is an associative array with context data.

function can_feature_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_feature_listing', 'can_feature_listing', 10);

Can Create User Review For Listing

Description

The "can_create_user_review_for_listing" filter is used to filter the user permission to create a new user review. This is different from the "listing_allows_user_reviews" filter because while a listing may allow user reviews, you can stop specific users from submitting user reviews.

Usage

When the "can_create_user_review_for_listing" filter is called, it is passed two arguments. The first argument is the current value for the create user review permission. The second argument is an associative array with context data.

function can_create_user_review_for_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_create_user_review_for_listing', 'can_create_user_review_for_listing', 10);

Can Create Editor Review For Listing

Description

The "can_create_editor_review_for_listing" filter is used to filter the user permission to create a new editor review. This is different from the "listing_allows_editor_reviews" filter because while a listing may allow editor reviews, you can stop specific users from submitting editor reviews.

Usage

When the "can_create_editor_review_for_listing" filter is called, it is passed two arguments. The first argument is the current value for the create user review permission. The second argument is an associative array with context data.

function can_create_editor_review_for_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_create_editor_review_for_listing', 'can_create_editor_review_for_listing', 10);

Can Add Review on Listing Create

Description

The "can_add_review_on_listing_create" filter is used to filter the user permission to add a review while creating a new listing.

Usage

When the "can_add_review_on_listing_create" filter is called, it is passed two arguments. The first argument is the current value for the user permission to add a review in the listing form. The second argument is an associative array with context data.

function can_add_review_on_listing_create($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_add_review_on_listing_create', 'can_add_review_on_listing_create', 10);

Can Update Listing Media

Description

The "can_update_listing_media" filter is used to filter the user permission to update listing media. This refers to media edit page that is reached via the "Edit Media" link in the listing's manage dropdown (the gear icon).

Usage

When the "can_update_listing_media" filter is called, it is passed two arguments. The first argument is the current value for update permission. The second argument is an associative array with context data.

function can_update_listing_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_update_listing_media', 'can_update_listing_media', 10);

Can Upload Listing Media

Description

The "can_upload_listing_media" filter is used to filter the user permission to upload listing media.

Usage

When the "can_upload_listing_media" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing media. The second argument is an associative array with context data.

function can_upload_listing_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_listing_media', 'can_upload_listing_media', 10);

Can Upload Listing Media From URL

Description

The "can_upload_media_from_url_in_listing" filter is used to filter the user permission to upload listing media with the upload from URL feature.

Usage

When the "can_upload_media_from_url_in_listing" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing media using a URL. The second argument is an associative array with context data.

function can_upload_media_from_url_in_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_media_from_url_in_listing', 'can_upload_media_from_url_in_listing', 10);

Can Upload Listing Photo

Description

The "can_upload_listing_photo" filter is used to filter the user permission to upload listing photos.

Usage

When the "can_upload_listing_photo" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing photos. The second argument is an associative array with context data.

function can_upload_listing_photo($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_listing_photo', 'can_upload_listing_photo', 10);

Can Upload Listing Video

Description

The "can_upload_listing_video" filter is used to filter the user permission to upload listing videos.

Usage

When the "can_upload_listing_video" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing videos. The second argument is an associative array with context data.

function can_upload_listing_video($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_listing_video', 'can_upload_listing_video', 10);

Can Upload Listing Audio

Description

The "can_upload_listing_audio" filter is used to filter the user permission to upload listing audio.

Usage

When the "can_upload_listing_audio" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing audio. The second argument is an associative array with context data.

function can_upload_listing_audio($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_listing_audio', 'can_upload_listing_audio', 10);

Can Upload Listing Attachment

Description

The "can_upload_listing_attachment" filter is used to filter the user permission to upload listing attachments.

Usage

When the "can_upload_listing_attachment" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload listing attachments. The second argument is an associative array with context data.

function can_upload_listing_attachment($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_listing_attachment', 'can_upload_listing_attachment', 10);

Media Permissions

Trusted On Create Photo

Description

The "trusted_on_create_photo" filter is used to filter the moderation setting when a new photo is uploaded.

Usage

When the "trusted_on_create_photo" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to upload photos without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Photo Uploads From Users With Published Media

If you want to use this approach for all types of media, then you can use the same callback function for all the filters.

function trust_published_media_users($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_media WHERE user_id = %d AND published = 1 AND approved = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
        return true;
    }
  }
 
    return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_photo', 'trust_published_media_users', 10);

Trusted On Create Video

Description

The "trusted_on_create_video" filter is used to filter the moderation setting when a new video is uploaded.

Usage

When the "trusted_on_create_video" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to upload videos without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Video Uploads From Users With Published Media

If you want to use this approach for all types of media, then you can use the same callback function for all the filters.

function trust_published_media_users($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_media WHERE user_id = %d AND published = 1 AND approved = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
        return true;
    }
  }
 
    return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_video', 'trust_published_media_users', 10);

Trusted On Create Audio

Description

The "trusted_on_create_audio" filter is used to filter the moderation setting when a new audio is uploaded.

Usage

When the "trusted_on_create_audio" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to upload audio without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Audio Uploads From Users With Published Media

If you want to use this approach for all types of media, then you can use the same callback function for all the filters.

function trust_published_media_users($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_media WHERE user_id = %d AND published = 1 AND approved = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
        return true;
    }
  }
 
    return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_audio', 'trust_published_media_users', 10);

Trusted On Create Attachment

Description

The "trusted_on_create_attachment" filter is used to filter the moderation setting when a new attachment is uploaded.

Usage

When the "trusted_on_create_attachment" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to upload attachments without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Attachment Uploads From Users With Published Media

If you want to use this approach for all types of media, then you can use the same callback function for all the filters.

function trust_published_media_users($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_media WHERE user_id = %d AND published = 1 AND approved = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
        return true;
    }
  }
 
    return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_attachment', 'trust_published_media_users', 10);

Media Allows Voting

Description

The "media_allows_voting" filter is used to filter the media likes feature.

Usage

When the "media_allows_voting" filter is called, it is passed two arguments. The first argument is the current value for media likes feature. The second argument is an associative array with context data. The likes feature is enabled only if the filter returns true.

Examples

Disable media likes
function disable_media_likes($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return false;
}
 
Clickfwd\Hook\Filter::add('media_allows_voting', 'disable_media_likes', 10);

Media Allows Report

Description

The "media_allows_report" filter is used to filter the media abuse reporting feature.

Usage

When the "media_allows_report" filter is called, it is passed two arguments. The first argument is the current value for media abuse reporting feature. The second argument is an associative array with context data. The reporting feature is enabled only if the filter returns true.

Examples

Disable media reporting for guest users
function disable_media_reporting_for_guests($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $auth = S2Object::make('auth');
 
  if ( !$auth->connected )
  {
    return false;
  }
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('media_allows_report', 'disable_media_reporting_for_guests', 10);

Can Update Media In Listing

Description

The "can_update_media_in_listing" filter is used to filter the user permission to update uploaded media details like title and description by using the edit icon for media which brings up the update dialog.

Usage

When the "can_update_media_in_listing" filter is called, it is passed two arguments. The first argument is the current value for update permission. The second argument is an associative array with context data.

function can_update_media_in_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_update_media_in_listing', 'can_update_media_in_listing', 10);

Can Delete Media In Listing

Description

The "can_delete_media_in_listing" filter is used to filter the user permission to delete uploaded media.

Usage

When the "can_delete_media_in_listing" filter is called, it is passed two arguments. The first argument is the current value for the user permission to delete media. The second argument is an associative array with context data.

function can_delete_media_in_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_delete_media_in_listing', 'can_delete_media_in_listing', 10);

Can Publish Media In Listing

Description

The "can_publish_media_in_listing" filter is used to filter the user permission to publish uploaded media.

Usage

When the "can_publish_media_in_listing" filter is called, it is passed two arguments. The first argument is the current value for the user permission to publish media. The second argument is an associative array with context data.

function can_publish_media_in_listing($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_publish_media_in_listing', 'can_publish_media_in_listing', 10);

Can Set Main Media

Description

The "can_set_main_media" filter is used to filter the user permission to change the main media.

Usage

When the "can_set_main_media" filter is called, it is passed two arguments. The first argument is the current value for the user permission to change the main media. The second argument is an associative array with context data.

function can_set_main_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_set_main_media', 'can_set_main_media', 10);

Can Vote on Media

Description

The "can_vote_on_media" filter is used to filter the user permission to like media. This is different from the "media_allows_voting" filter because even if the media like feature is visible, with this filter you can stop specific users from liking media.

Usage

When the "can_vote_on_media" filter is called, it is passed two arguments. The first argument is the current value for the user permission to like media. The second argument is an associative array with context data.

function can_vote_on_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_vote_on_media', 'can_vote_on_media', 10);

Can Report Media

Description

The "can_report_media" filter is used to filter the user permission to report media. This is different from the "media_allows_report" filter because even if the media report feature is visible, with this filter you can stop specific users from reporting media.

Usage

When the "can_report_media" filter is called, it is passed two arguments. The first argument is the current value for the user permission to report media. The second argument is an associative array with context data.

function can_report_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_report_media', 'can_report_media', 10);

Can Download Attachment

Description

The "can_download_attachment" filter is used to filter the user permission to download attachments.

Usage

When the "can_download_attachment" filter is called, it is passed two arguments. The first argument is the current value for the user permission to download attachments. The second argument is an associative array with context data. If your site has a membership functionality, you could use this filter to only allow certain types of members to download media by including some code from the membership solution to check the logged in user's membership plan.

function can_download_attachment($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_download_attachment', 'can_download_attachment', 10);

Review Permissions

Trusted on Create User Review

Description

The "trusted_on_create_user_review" filter is used to filter the moderation setting when a new user review is created.

Usage

When the "trusted_on_create_user_review" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create user reviews without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Review Submissions From Users With Published Reviews
function trust_published_reviewers($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_comments WHERE userid = %d AND published = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
      return true;
    }
  }
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_user_review', 'trust_published_reviewers', 10);

Trusted on Update User Review

Description

The "trusted_on_update_user_review" filter is used to filter the moderation setting when a user review is updated.

Usage

When the "trusted_on_update_user_review" filter is called, it is passed two arguments. The first argument is the current value of the update moderation setting. The value is true when the user is trusted to update reviews without moderation and false otherwise. The second argument is an associative array with context data.

function trusted_on_update_user_review($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_update_user_review', 'trusted_on_update_user_review', 10);

Trusted on Create Editor Review

Description

The "trusted_on_create_editor_review" filter is used to filter the moderation setting when a new editor review is created.

Usage

When the "trusted_on_create_editor_review" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create editor reviews without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Review Submissions From Users With Published Reviews
function trust_published_reviewers($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_comments WHERE userid = %d AND published = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
      return true;
    }
  }
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_editor_review', 'trust_published_reviewers', 10);

Trusted on Update Editor Review

Description

The "trusted_on_update_editor_review" filter is used to filter the moderation setting when a editor review is updated.

Usage

When the "trusted_on_update_editor_review" filter is called, it is passed two arguments. The first argument is the current value of the update moderation setting. The value is true when the user is trusted to update reviews without moderation and false otherwise. The second argument is an associative array with context data.

function trusted_on_update_editor_review($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_update_editor_review', 'trusted_on_update_editor_review', 10);

Trusted on Create Review Owner Reply

Description

The "trusted_on_create_review_owner_reply" filter is used to filter the moderation setting when a listing owner replies to a review.

Usage

When the "trusted_on_create_review_owner_reply" filter is called, it is passed two arguments. The first argument is the current value of the owner reply moderation setting. The value is true when the user is trusted to reply to reviews without moderation and false otherwise. The second argument is an associative array with context data.

function trusted_on_create_review_owner_reply($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_review_owner_reply', 'trusted_on_create_review_owner_reply', 10);

Review Allows Report

Description

The "review_allows_report" filter is used to filter the review abuse reporting feature.

Usage

When the "review_allows_report" filter is called, it is passed two arguments. The first argument is the current value for review abuse reporting feature. The second argument is an associative array with context data. The reporting feature is enabled only if the filter returns true.

Examples

Disable review reporting for guest users
function disable_review_reporting_for_guests($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $auth = S2Object::make('auth');
 
  if ( !$auth->connected )
  {
    return false;
  }
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('review_allows_report', 'disable_review_reporting_for_guests', 10);

Review Allows Voting

Description

The "review_allows_voting" filter is used to filter the review helpfulness voting feature.

Usage

When the "review_allows_voting" filter is called, it is passed two arguments. The first argument is the current value for review helpfulness voting. The second argument is an associative array with context data. The helpfulness voting is enabled only if the filter returns true.

Examples

Disable review helpfulness voting
function disable_review_voting($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return false;
}
 
Clickfwd\Hook\Filter::add('review_allows_voting', 'disable_review_voting', 10);

Review Allows Replies

Description

The "review_allows_replies" filter is used to filter the owner reply feature.

Usage

When the "review_allows_replies" filter is called, it is passed two arguments. The first argument is the current value for owner replies. The second argument is an associative array with context data. Owner replies are enabled only if the filter returns true.

function review_allows_replies($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return false;
}
 
Clickfwd\Hook\Filter::add('review_allows_replies', 'review_allows_replies', 10);

Review Allows Discussions

Description

The "review_allows_discussions" filter is used to filter the revie discussion feature.

Usage

When the "review_allows_discussions" filter is called, it is passed two arguments. The first argument is the current value for owner replies. The second argument is an associative array with context data. Owner replies are enabled only if the filter returns true.

function review_allows_discussions($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  return false;
}
 
Clickfwd\Hook\Filter::add('review_allows_discussions', 'review_allows_replies', 10);

Can Update Review

Description

The "can_update_review" filter is used to filter the user permission to update a review.

Usage

When the "can_update_review" filter is called, it is passed two arguments. The first argument is the current value for the review update permission. The second argument is an associative array with context data.

function can_update_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_update_review', 'can_update_review', 10);

Can Delete Review

Description

The "can_delete_review" filter is used to filter the user permission to update a review.

Usage

When the "can_delete_review" filter is called, it is passed two arguments. The first argument is the current value for the review delete permission. The second argument is an associative array with context data.

function can_delete_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_delete_review', 'can_delete_review', 10);

Can Reply To Review

Description

The "can_reply_to_review" filter is used to filter the user permission to reply to a review.

Usage

When the "can_reply_to_review" filter is called, it is passed two arguments. The first argument is the current value for the create review reply permission. The second argument is an associative array with context data.

function can_reply_to_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_reply_to_review', 'can_reply_to_review', 10);

Can Delete Review Reply

Description

The "can_delete_review_reply" filter is used to filter the user permission to delete a review reply.

Usage

When the "can_delete_review_reply" filter is called, it is passed two arguments. The first argument is the current value for the delete review reply permission. The second argument is an associative array with context data.

function can_delete_review_reply($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_delete_review_reply', 'can_delete_review_reply', 10);

Can Report Review

Description

The "can_report_review" filter is used to filter the user permission to report a review.

Usage

When the "can_report_review" filter is called, it is passed two arguments. The first argument is the current value for the report review permission. The second argument is an associative array with context data.

function can_report_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_report_review', 'can_report_review', 10);

Can Vote On Review

Description

The "can_vote_on_review" filter is used to filter the user permission to vote on a review's helpfulness.

Usage

When the "can_vote_on_review" filter is called, it is passed two arguments. The first argument is the current value for the review vote permission. The second argument is an associative array with context data.

function can_vote_on_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_vote_on_review', 'can_vote_on_review', 10);

Can Create Review Comment

Description

The "can_create_review_post" filter is used to filter the user permission to write a comment about a review.

Usage

When the "can_create_review_post" filter is called, it is passed two arguments. The first argument is the current value for the write comment permission. The second argument is an associative array with context data.

function can_create_review_post($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_create_review_post', 'can_create_review_post', 10);

Can Upload Review Media

Description

The "can_upload_review_media" filter is used to filter the user permission to upload media to a review.

Usage

When the "can_upload_review_media" filter is called, it is passed two arguments. The first argument is the current value for the upload review media permission. The second argument is an associative array with context data.

function can_upload_review_media($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_review_media', 'can_upload_review_media', 10);

Can Upload Review Media From URL

Description

The "can_upload_media_from_url_in_review" filter is used to filter the user permission to upload review media with the upload from URL feature.

Usage

When the "can_upload_media_from_url_in_review" filter is called, it is passed two arguments. The first argument is the current value for the user permission to upload review media using a URL. The second argument is an associative array with context data.

function can_upload_media_from_url_in_review($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_media_from_url_in_review', 'can_upload_media_from_url_in_review', 10);

Can Upload Review Photo

Description

The "can_upload_review_photo" filter is used to filter the user permission to upload photos to a review.

Usage

When the "can_upload_review_photo" filter is called, it is passed two arguments. The first argument is the current value for the upload review photo permission. The second argument is an associative array with context data.

function can_upload_review_photo($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_review_photo', 'can_upload_review_photo', 10);

Can Upload Review Video

Description

The "can_upload_review_video" filter is used to filter the user permission to upload videos to a review.

Usage

When the "can_upload_review_video" filter is called, it is passed two arguments. The first argument is the current value for the upload review video permission. The second argument is an associative array with context data.

function can_upload_review_video($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_review_video', 'can_upload_review_video', 10);

Can Upload Review Audio

Description

The "can_upload_review_audio" filter is used to filter the user permission to upload audio to a review.

Usage

When the "can_upload_review_audio" filter is called, it is passed two arguments. The first argument is the current value for the upload review audio permission. The second argument is an associative array with context data.

function can_upload_review_audio($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_review_audio', 'can_upload_review_audio', 10);

Can Upload Review Attachment

Description

The "can_upload_review_attachment" filter is used to filter the user permission to upload attachments to a review.

Usage

When the "can_upload_review_attachment" filter is called, it is passed two arguments. The first argument is the current value for the upload review attachment permission. The second argument is an associative array with context data.

function can_upload_review_attachment($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_upload_review_attachment', 'can_upload_review_attachment', 10);

Review Discussion Permissions

Trusted on Create Review Discussion

Description

The "trusted_on_create_review_discussion" filter is used to filter the moderation setting when a new review discussion comment is created.

Usage

When the "trusted_on_create_review_discussion" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create user review discussions without moderation and false otherwise. The second argument is an associative array with context data.

Examples

Trust All Review Submissions From Users With Published Reviews

In this example any user with a published review will also be able to comment on other reviews without the need for moderation.

function trust_published_reviewers($trust, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($trust, $params);
 
  $auth = S2Object::make('auth');
 
  if ( $auth->id > 0 )
  {
    $Model = new S2Model();
 
    $query = sprintf('SELECT count(*) FROM #__jreviews_comments WHERE userid = %d AND published = 1', $auth->id);
 
    $count = $Model->query($query,'loadResult');
 
    if ( $count > 0 )
    {
      return true;
    }
  }
 
  return $trust;
}
 
Clickfwd\Hook\Filter::add('trusted_on_create_review_discussion', 'trust_published_reviewers', 10);

Review Discussion Allows Report

Description

The "review_discussion_allows_report" filter is used to filter the review discussion abuse reporting feature.

Usage

When the "review_discussion_allows_report" filter is called, it is passed two arguments. The first argument is the current value for review discussion abuse reporting feature. The second argument is an associative array with context data. The reporting feature is enabled only if the filter returns true.

Examples

Disable review discussion reporting for guest users
function disable_review_discussion_reporting_for_guests($allow, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($allow, $params);
 
  $auth = S2Object::make('auth');
 
  if ( !$auth->connected )
  {
    return false;
  }
 
  return $allow;
}
 
Clickfwd\Hook\Filter::add('review_discussion_allows_report', 'disable_review_discussion_reporting_for_guests', 10);

Can Report Review Discussion

Description

The "can_report_review_discussion" filter is used to filter the user permission to report review discussions. This is different from the "review_discussion_allows_report" filter because even if the review discussion report feature is visible, with this filter you can stop specific users from reporting review discussions.

Usage

When the "can_report_review_discussion" filter is called, it is passed two arguments. The first argument is the current value for the user permission to report review discussions. The second argument is an associative array with context data.

function can_report_review_discussion($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_report_review_discussion', 'can_report_review_discussion', 10);

Can Update Review Discussion

Description

The "can_update_review_discussion" filter is used to filter the user permission to update a review discussion comment.

Usage

When the "can_update_review_discussion" filter is called, it is passed two arguments. The first argument is the current value for the review discussion update permission. The second argument is an associative array with context data.

function can_update_review_discussion($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_update_review_discussion', 'can_update_review_discussion', 10);

Can Delete Review Discussion

Description

The "can_delete_review_discussion" filter is used to filter the user permission to delete a review discussion comment.

Usage

When the "can_delete_review_discussion" filter is called, it is passed two arguments. The first argument is the current value for the delete permission. The second argument is an associative array with context data.

function can_delete_review_discussion($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_delete_review_discussion', 'can_delete_review_discussion', 10);

Field Permissions

Can View Field in Listing Detail Page

Description

The "can_view_field_in_detail_page" filter is used to filter the user permission to view custom fields in the listing detail page.

Usage

When the "can_view_field_in_detail_page" filter is called, it is passed two arguments. The first argument is the current value for the view field permission. The second argument is an associative array with context data.

function can_view_field_in_detail_page($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_view_field_in_detail_page', 'can_view_field_in_detail_page', 10);

Can View Field in Listing List Page

Description

The "can_view_field_in_list_page" filter is used to filter the user permission to view custom fields in the listing list pages.

Usage

When the "can_view_field_in_list_page" filter is called, it is passed two arguments. The first argument is the current value for the view field permission. The second argument is an associative array with context data.

function can_view_field_in_list_page($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_view_field_in_list_page', 'can_view_field_in_list_page', 10);

Can View Field in Listing Comparison Page

Description

The "can_view_field_in_comparison_page" filter is used to filter the user permission to view custom fields in the listing comparison page.

Usage

When the "can_view_field_in_comparison_page" filter is called, it is passed two arguments. The first argument is the current value for the view field permission. The second argument is an associative array with context data.

function can_view_field_in_comparison_page($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_view_field_in_comparison_page', 'can_view_field_in_comparison_page', 10);

Can Read Field

Description

The "can_read_field" filter is used to filter the user permission to view the output of custom fields. While the "can_view_field__..." filter is specific to certain pages, this filter works on all pages.

Usage

When the "can_read_field" filter is called, it is passed two arguments. The first argument is the current value for the read field permission. The second argument is an associative array with context data.

Examples

Hide a specific custom field
function hide_city_field($permission, $params)
{
    // Uncomment line below to dump filter arguments to the screen
    // dd($permission, $params);
 
    $field = $params['field'];
 
    if ( $field['name'] == 'jr_city' )
    {
        return false;
    }
 
    return $permission;
}
 
Clickfwd\Hook\Filter::add('can_read_field', 'hide_city_field', 10);

Can Write Field

Description

The "can_write_field" filter is used to filter the user permission to access field inputs in forms.

Usage

When the "can_write_field" filter is called, it is passed two arguments. The first argument is the current value for the write field permission. The second argument is an associative array with context data.

function can_write_field($permission, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('can_write_field', 'can_write_field', 10);

EngageUsers

Category Allows Follows

Description

The "category_allows_follows" filter lets you specifically enable or disable the follow button for specific categories.

Usage

When the "category_allows_follows" filter is called, it is passed two arguments. The first is Boolean $allow permission which is true by default. The second is an Array of parameters, including the category in $params['cat'].

function category_allows_follows($allow, $params)
{
	return $allow;
}
 
Clickfwd\Hook\Filter::add('category_allows_follows', 'category_allows_follows', 10);

Examples

Show follow button only in specific categories
function category_allows_follows($allow, $params)
{
	$allowCatIds = [1,2,3,4,5]; // List of cat ids where you want to allow the button to show
 
        return in_array($params['params']['cat'], $allowCatIds); 
 }
 
Clickfwd\Hook\Filter::add('category_allows_follows', 'category_allows_follows', 10);
Hide follow button in specific categories
function category_disallows_follows($allow, $params)
{
	$disallowCatIds = [1,2,3,4,5]; // List of cat ids where you want to hide the follow button
 
        return !in_array($params['params']['cat'], $disallowCatIds); 
 }
 
Clickfwd\Hook\Filter::add('category_allows_follows', 'category_disallows_follows', 10);

Listing Search Allows Alert

Description

The "listing_search_allows_alert" filter lets you specifically enable or disable the alert button in search results.

Usage

When the "listing_search_allows_alert" filter is called, it is passed two arguments. The first is Boolean $allow permission which is true by default. The second is an Array of parameters.

function listing_search_allows_alert($allow, $params)
{
	return $allow;
}
 
Clickfwd\Hook\Filter::add('listing_search_allows_alert', 'listing_search_allows_alert', 10);

GeoMaps

Google Maps Api Url

Description

The "google_maps_api_url" filter lets you modify the Google Maps API base URL.

Usage

When the "google_maps_api_url" filter is called, it is one argument with the current API base URL. While there is already a setting for the URL in the add-on configuration, there may be instances where a dynamic change is required depending on user location. For example, for sites in China, the Google Maps API URL must load using HTTP, while the same sites loaded from outside of China can use HTTPS.

function google_maps_api_url($url)
{
	return $url;
}
 
Clickfwd\Hook\Filter::add('google_maps_api_url', 'google_maps_api_url', 10);

UserProfiles Add-on

UserProfiles Account Sections

Description

The "userprofiles_account_sections" filter lets you modify the UserProfiles account page by allowing you to add or remove sections from it.

Usage

When the "userprofiles_account_sections" filter is called, it is passed two arguments. The first argument is an array with the account sections. The second argument is an associative array with context data.

function userprofiles_account_sections($sections, $params)
{
  // Uncomment line below to dump filter arguments to the screen
  // dd($permission, $params);
 
  return $permission;
}
 
Clickfwd\Hook\Filter::add('userprofiles_account_sections', 'userprofiles_account_sections', 10);

Examples

Show 3rd party solution membership information

If you have a membership solution from another provider on your site, you could show information about the user's membership status or link to the membership management page.

function userprofiles_account_sections($sections, $params = [])
{
  $userId = array_get($params,'user.User.id');
 
    $sections['membership'] = [
        'title'=>'Your Membership Status',
        'summary'=>'Below you can find the details of your current membership plan',
        'body'=>'<p>Here you can add a link to the membership page or if you have the code to lookup membership info you can insert the rendered template with that information here</p>'
    ];
 
  return $sections;
}
 
Clickfwd\Hook\Filter::add('userprofiles_account_sections', 'userprofiles_account_sections', 10);

Listing Resources Add-on

Resources Form Bottom

Description

The "resources_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "resources_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

Resources Submit Validation

Description

The "resources_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "resources_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Resources Save Pre

Description

The "resources_save_pre" filter is used to filter the submitted form data before it is stored in the database.

Usage

When the "resources_save_pre" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data.

Listing Allows Resources

Description

The "listing_allows_resources" filter is used to filter the setting that enables listing resources for a listing.

Usage

When the "listing_allows_resources" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data. Resources is only enabled for a listing if the callback function returns true.

Trusted On Listing Resource Create

Description

The "trusted_on_listing_resource_create" filter is used to filter the moderation setting when a new resource is created.

Usage

When the "trusted_on_listing_resource_create" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create resources without moderation and false otherwise. The second argument is an associative array with context data.

Can Create Listing Resource

Description

The "can_create_listing_resource" filter is used to filter the user permission to create a resource.

Usage

When the "can_create_listing_resource" filter is called, it is passed two arguments. The first argument is the current value for the create resource permission. The second argument is an associative array with context data.

Can Update Listing Resource

Description

The "can_update_listing_resource" filter is used to filter the user permission to update a listing resource.

Usage

When the "can_update_listing_resource" filter is called, it is passed two arguments. The first argument is the current value for the listing resource update permission. The second argument is an associative array with context data.

Can Delete Listing Resource

Description

The "can_delete_listing_resource" filter is used to filter the user permission to delete a listing resource.

Usage

When the "can_delete_listing_resource" filter is called, it is passed two arguments. The first argument is the current value for the delete permission. The second argument is an associative array with context data.

MyLists Add-on

MyLists Form Bottom

Description

The "mylists_form_bottom" filter is used to programmatically add code at the bottom of the form, above the submit button.

Usage

When the "mylists_form_bottom" filter is called, it is passed two arguments. The first argument is a string that can be used to append or prepend new code. The second argument is an associative array with context data like the 'is_new' parameter to indicate whether it's a new entry or an update.

MyLists Submit Validation

Description

The "mylists_submit_validation" filter is used to programmatically filter the validation array when a form is submitted.

Usage

When the "mylists_submit_validation" filter is called, it is passed two arguments. The first argument is an array with all the current validation messages. The second argument is an associative array with context data, including the form posted data.

Listing Allows User Lists

Description

The "listing_allows_user_lists" filter is used to filter the setting that enables users lists for a listing.

Usage

When the "listing_allows_user_lists" filter is called, it is passed two arguments. The first argument is an array of the posted data. The second argument is an associative array with context data. User lists is only enabled for a listing if the callback function returns true.

Trusted On User List Create

Description

The "trusted_on_user_list_create" filter is used to filter the moderation setting when a new user list is created.

Usage

When the "trusted_on_user_list_create" filter is called, it is passed two arguments. The first argument is the current value of the moderation setting. The value is true when the user is trusted to create user lists without moderation and false otherwise. The second argument is an associative array with context data.

Can Create User List

Description

The "can_create_user_list" filter is used to filter the user permission to create a user list.

Usage

When the "can_create_user_list" filter is called, it is passed two arguments. The first argument is the current value for the create user list permission. The second argument is an associative array with context data.

Can Update User List

Description

The "can_update_user_list" filter is used to filter the user permission to update a user list.

Usage

When the "can_update_user_list" filter is called, it is passed two arguments. The first argument is the current value for the user list update permission. The second argument is an associative array with context data.

Can Delete User List

Description

The "can_delete_user_list" filter is used to filter the user permission to delete a user list.

Usage

When the "can_delete_user_list" filter is called, it is passed two arguments. The first argument is the current value for the delete permission. The second argument is an associative array with context data.

Can Publish User List

Description

The "can_publish_user_list" filter is used to filter the user permission to publish a user list.

Usage

When the "can_publish_user_list" filter is called, it is passed two arguments. The first argument is the current value for the publish permission. The second argument is an associative array with context data.

Can Make User List Private

Description

The "can_make_user_list_private" filter is used to filter the user permission to change the private status a user list.

Usage

When the "can_make_user_list_private" filter is called, it is passed two arguments. The first argument is the current value for the private setting permission. The second argument is an associative array with context data.