PluginProbe
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) / trunk
Analytify – Google Analytics Dashboard For WordPress (GA4 analytics tracking) vtrunk
9.1.2 9.1.1 9.1.0 9.0.2 9.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 All 153 releases
← All changes | inc/utils.php +23 -0 9.0.2trunk View file →
@@ -178,11 +178,30 @@
178 178 }
179 179 }
180 180
181 181 /**
182 + * Whether the current user is a subscriber blocked from Analytify admin UI.
183 + *
184 + * @since 9.1.0
185 + * @version 9.1.0
186 + * @return bool
187 + */
188 + public static function is_subscriber_blocked_from_analytify() {
189 + if ( ! is_user_logged_in() ) {
190 + return false;
191 + }
192 +
193 + $user = wp_get_current_user();
194 + $roles = (array) $user->roles;
195 +
196 + return in_array( 'subscriber', $roles, true ) && ! in_array( 'administrator', $roles, true );
197 + }
198 +
199 + /**
182 200 * Check current user role - Legacy function from main file
183 201 *
184 202 * @since 1.2.2
203 + * @version 9.1.0
185 204 * @param array<string, mixed> $access_level selected access level.
186 205 * @return boolean
187 206 */
188 207 public static function pa_check_roles( $access_level ) {
@@ -190,8 +209,12 @@
190 209 // Convert string to array if none of the role selected.
191 210 $access_level = (array) $access_level;
192 211
193 212 if ( is_user_logged_in() && ! empty( $access_level ) ) {
213 +
214 + if ( self::is_subscriber_blocked_from_analytify() ) {
215 + return false;
216 + }
194 217
195 218 global $current_user;
196 219 $roles = $current_user->roles;
197 220