WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Cache only for admin users (5 posts)

  1. Daniel Roch
    Member
    Posted 3 years ago #

    Hello,

    I want to add an option, or a hack to Wp Super cache in order to cache pages for every user, except admin users.

    I just found an admin option, but it includes every user with comments...

    How can i do such thing ?

    Thanks for your help.

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    You'll have to modify the check in wp-cache-phase2.php so it only checks is_logged_in() instead of the cookies. Unfortunately you'll have to do that modification every time you upgrade.

  3. Daniel Roch
    Member
    Posted 3 years ago #

    Thanks for your help.

    The solution is to add this code into the functions.php of the theme : :

    global $super_cache_enabled;
    if ( is_user_logged_in() ) {
    	$super_cache_enabled = false;
    	$cache_enabled = false;
    	if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching for user logged In.', 5 );}
  4. Daniel Roch
    Member
    Posted 3 years ago #

    I am mistaken : it doesn't work in the functions.php file.

    This code must be included in wp-cache-phase2, on line 360

    if ( is_user_logged_in() ) {
    	$super_cache_enabled = false;
    	$cache_enabled = false;
    	if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Not caching for user logged In.', 5 );}
  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Actually, there's a hook in the cookie function. You could hook into that and check is_user_logged_in().

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic