diff --git a/filter.php b/filter.php index 13004ad..2aa2a50 100644 --- a/filter.php +++ b/filter.php @@ -3939,15 +3939,22 @@ function ($matches) use ($USER) { if ($found > 0) { foreach ($matches[1] as $key => $match) { $fieldname = $matches[1][$key]; - // Do not process tag if the specified profile field name does not exist. - if (!array_key_exists($fieldname, $profilefields)) { - continue; - } - $string = $matches[0][$key]; // String found in $text. $operator = $matches[2][$key]; $value = $matches[3][$key]; + // Do not process tag if the specified profile field name does not exist or user is not logged in. + if (!array_key_exists($fieldname, $profilefields) || !isloggedin() || isguestuser()) { + if ($operator == 'not') { + // It will always meet criteria of a "not" if the user doesn't have a profile. + $replace['/' . preg_quote($string, '/') . '/isuU'] = $matches[4][$key]; + } else { + // It will never match the criteria "is", "contains" or "in" if the user doesn't have a profile. + $replace['/' . preg_quote($string, '/') . '/isuU'] = ''; + } + continue; + } + if (!empty($value)) { $value = trim($value, '"'); // Trim quotation marks. } diff --git a/version.php b/version.php index 62d16d8..8d1a04d 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024072200; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024072201; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014051200; // Requires Moodle version 2.7 or later. $plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics). $plugin->release = '2.5.2';