Welcome Guest, Not a member yet? Register   Sign In
Community Auth - Use to selectivly display content on page
#1

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
Reply
#2

(This post was last modified: 11-27-2018, 07:56 AM by xBarns.)

(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.
Reply
#3

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

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

Thank you very much!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB