Show only if user-role is subscriber AND site visitor
-
Hi, I am a bit stuck with the code below for my WordPress site. This code will be used in the Ad Inserter Head section to disable the Adsense Code for particular user-roles:
<?php $user = wp_get_current_user(); $allowed_roles = array('subscriber', 'visitor'); if ( array_intersect($allowed_roles, $user->roles ) ) echo '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXX" crossorigin="anonymous"></script>' ?>
I want the Adsense code only be shown in the HEAD section for site visitors and the user role SUBSCRIBER. I tried ‘visitor’ but that didn’t worked because that doesn’t exist.
Thanks in advance
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Show only if user-role is subscriber AND site visitor’ is closed to new replies.