• Resolved FlatText

    (@flattext)


    After installing this very useful plugin, all visitors get hit with the pop-up ‘Allow notifications from this site?’.

    Can we disable it for non-logged in users?

    These notifications are meant for back-end users only.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello there,

    I hope you’re doing well ??

    If you want to disable notifications for non-logged in users, please add the following code on your functions.php of your active theme:

    if( class_exists('YITH_WCDN_Desktop_Notifications_Notify') ) {
        
        if (!function_exists('yith_wcdn_disable_enqueue_script_no_logged_users')) {
    
            add_action('init', 'yith_wcdn_disable_enqueue_script_no_logged_users');
    
            function yith_wcdn_disable_enqueue_script_no_logged_users()
            {
    
                if (!is_user_logged_in() || !current_user_can('manage_options')) {
                    $instance = YITH_WCDN_Desktop_Notifications_Notify::get_instance();
                    remove_action('wp_enqueue_scripts', array($instance, 'enqueue_styles_scripts'), 11);
                }
    
            }
        }
    }

    Please, try it and let me know.

    Have a good day.

    Thread Starter FlatText

    (@flattext)

    Thanks Carlos, that worked

    • This reply was modified 5 years, 1 month ago by FlatText.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Notifications for logged in users only’ is closed to new replies.