• Hello, first of all thank you for this plugin, it works perfectly.
    I provide ad-free membership in my website. So I want to disable adblock alert for “Subscriber” user role.

    I tried to deregister js and css files by adding the following code to the functions.php file, but it didn’t work. Can you provide a solution?

    function adblock_dequeue_styles() { 
        if ( current_user_can( 'subscriber' ) ) {
            wp_dequeue_script( 'chp-ads-alerty-js' );
            wp_dequeue_style( 'chp-ads-alerty-css' );
        }
    }
    add_action( 'wp_print_styles', 'adblock_dequeue_styles' );
    • This topic was modified 2 years, 9 months ago by Furkan Ağlar.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Suresh Chand

    (@sureshchand12a)

    Hi Furkan Ağlar,

    Please update plugin to latest version(2.5.2) and use below filter hook to disable the plugin. You can customize any plugin settings using this hook.

    /**
     * Filter to disable all customize the settings.
     * 
     * @param array $settings
     */
    
     add_filter( 'adb/modify/settings', function($settings){
            if ( current_user_can( 'subscriber' ) ) {
                    $settings['enable'] = false;
            }
     	return $settings;
     });

    For more details, Check documentation

    Thread Starter Furkan Ağlar

    (@frkn64)

    Many thanks for your quick response and help!

    The code you provided works perfectly when I log in as a subscriber, but when I log in as an admin, it always shows the warning message whether adblocker is on or off. To solve this I changed the if structure to:
    if ( current_user_can( 'administrator' ) or current_user_can( 'subscriber' ) )

    Thanks again, have a nice day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disabling adblock alert for specific user role’ is closed to new replies.