Only load code when user is logged in

[ad_1]

@atvrequis you can unload CSS/JS on specific pages if the user is not logged in. You can even unload hardcoded assets and whole plugins, if you’re using the Pro version. What kind of code do you want to unload? If it’s just a PHP snippet that you have somewhere inside a plugin or the functions.php file, there’s no such feature in Asset CleanUp.

Yeah I thought it could, I guess I just can’t find it or don’t know where to look.

For example, some css or js code.

View post on imgur.com

How would I unload this so it only loads for logged in users ?

Thanks!

I think I found it, unload that specific code and then check the “but do load when user is logged in” exception.

That is correct. You can unload it site-wide, and make an exception by choosing to load it when the user is logged-in. The function that is missing is unloading an asset if the user is logged-in. Sometimes, there is specific code (e.g. analytics one) that should only be loaded by guests. I am considering implementing something like this.

Is the option you found enough for what you need?

Yup, this should do it for me. Thanks Gabe!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer