AI Zone Admin Forum Add your forum
Check if User has access to CP
 
 

Just a simple plugin that checks if the User that is currently logged in also has the right to login to the EE CP.


Therefore I’ve created this plugin that checks the Session of the current visitor:

The code (/eekernel/plugins/cp_access.php)

<?php
$plugin_info 
= array(
                        
'pi_name'           => 'CP Access',
                        
'pi_version'        => '1.0',
                        
'pi_author'         => 'Boris Toet',
                        
'pi_author_url'     => 'http://www.score-advertising.nl',
                        
'pi_description'    => 'Determines if the current visitor has CP access.',
                        
'pi_usage'          => Cp_access::usage()
                    );


class 
Cp_access
{
    
var $return_data "";

    function 
Cp_access() {
        
global $TMPL;
        global 
$SESS;

        if(
$SESS->userdata['can_access_cp'== 'y'{
            $this
->return_data $TMPL->tagdata;
        
else {
            $this
->return_data '';
        
}
    }

    
function usage()
    
{
        ob_start
(); 
  
?>

~~~~~~~~~~~~~~~~~~~~~~~ CP Access ~~~~~~~~~~~~~~~~~~~~~~~

As 
simple as it gets... just put {exp:cp_access} tags around stuff you only want
visible to Members with CP access
:

{exp:cp_access}Only Visible to Members with CP Access{/exp:cp_access}



        <?php
        $buffer 
ob_get_contents();
        
        
ob_end_clean(); 

        return 
$buffer;
    
}
    
/* END */
    
}
?> 

Usage:

{exp:cp_access}This only gets shown to those with CP acceess{/exp:cp_access} 
 

 
 
  login or register to react