Support Forum Support Forum GDPR Cookie Compliance Disable scripts for admin users

Topic Resolution: Resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Avatarmow187
    January 29, 2020 @ 10:10 am

    Hello! I would like to disable the analytics scripts for the administrator users. A found some hooks in your support like ‘moove_gdpr_third_party_header_assets’ and i tried all of them, but not working.
    With this code in the functions.php, the page need to stop, but it’s already working:
    function moove_gdpr_third_party_header_assets($scripts) {
    die(‘test’);
    }
    add_action(‘moove_gdpr_third_party_header_assets’, ‘moove_gdpr_third_party_header_assets’);

    I need just a code, that deletes all of the scripts when the administrator is logged in! Please help me!
    Thank you!

    Moove AgencyMoove Agency
    January 31, 2020 @ 9:42 am

    Hi mow187,

    Thanks for your comments.

    You can use the following code snippet for this purpose:

    add_action( 'gdpr_lss_extension', 'gdpr_scripts_scripts' );
    function gdpr_scripts_scripts( $scripts_to_inject ) {
    	if ( current_user_can( 'administrator' ) ):
    		$scripts_to_inject = array();
    	endif;
    	return $scripts_to_inject;
    }

    Hope this helps.

    Avatarmow187
    January 31, 2020 @ 10:29 am

    Thank you for the help!

Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.