Support » Plugin: SG Optimizer » Purge / Clear cache other user roles

  • Resolved Columbus

    (@christof15)


    Hi, is it possible to allow other user roles f.e. editor to purge / clear cache from the admin bar?

    – It is! –

    add_action( 'admin_bar_menu', 'add_admin_bar_purge_editor', '90' );
    function add_admin_bar_purge_editor ( $wp_admin_bar ){
    		$args = array(
    				'id'    => 'SG_CachePress_Supercacher_Purge',
    				'title' => __('Refresh website','sg-cachepress'),
    				'href'  => wp_nonce_url( admin_url( 'admin-post.php?action=sg-cachepress-purge' ),'sg-cachepress-purge' ),
    				'meta'  => array( 'class' => 'sg-cachepress-admin-bar-purge' )
    		);
    		if ( current_user_can('delete_pages') ) {
    			$wp_admin_bar->add_node( $args );
    		}
    	}
    • This topic was modified 1 year, 8 months ago by Columbus.
    • This topic was modified 1 year, 8 months ago by Columbus.
    • This topic was modified 1 year, 8 months ago by Columbus.
    • This topic was modified 1 year, 8 months ago by Columbus.
Viewing 1 replies (of 1 total)
  • Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Yes, we have a public function to purge the cache exactly for such cases:

    if (function_exists(‘sg_cachepress_purge_cache’)) {
    sg_cachepress_purge_cache();
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Purge / Clear cache other user roles’ is closed to new replies.