CodeIgniter Forums
Community Auth - Use to selectivly display content on page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Community Auth - Use to selectivly display content on page (/showthread.php?tid=72252)



Community Auth - Use to selectivly display content on page - xBarns - 11-27-2018

Hi all,

thanks for this nice plugin, i had some trouble setting it up but reading helped me big time.

One thing i could not achieve though was content on a page depending on a role.

i tried using 


PHP Code:
<?php
    
if( $this->require_role('admin') ) {
        echo 
'<a href="'.echo base_url(). 'index.php/advertsize/">Anzeigengr&ouml;&szlig;e</a>';
    }
?>

but this leads to the error:

Fatal error: Call to undefined method MY_Loader::require_role() in ...

Which i think is because i am calling this from a .php page and not a Controller.

How would i implement such a thing?

Thanks a lot.
x


RE: Community Auth - Use to selectivly display content on page - xBarns - 11-27-2018

(11-27-2018, 02:56 AM)xBarns Wrote: Hi all,

thanks for this nice plugin, i had some trouble setting it up but reading helped me big time.

One thing i could not achieve though was content on a page depending on a role.

i tried using 


PHP Code:
<?php
    if
$this->require_role('admin') ) {
 
       echo '<a href="'.echo base_url(). 'index.php/advertsize/">Anzeigengr&ouml;&szlig;e</a>';
 
   }
?>

but this leads to the error:

Fatal error: Call to undefined method MY_Loader::require_role() in ...

Which i think is because i am calling this from a .php page and not a Controller.

How would i implement such a thing?

Thanks a lot.
x

I think i found the answer, in some other thread:

PHP Code:
if( isset( $auth_level ) && $auth_level >= 10 


should do it, still need to verify first though.


RE: Community Auth - Use to selectivly display content on page - skunkbad - 11-27-2018

Depends if you are in a view, controller, model... see https://community-auth.com/documentation/usage/authentication-variables


RE: Community Auth - Use to selectivly display content on page - xBarns - 11-28-2018

(11-27-2018, 11:23 AM)skunkbad Wrote: Depends if you are in a view, controller, model... see https://community-auth.com/documentation/usage/authentication-variables

Thank you very much!