This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello,
I would like to check user permission to display some markup only to authorized users. How can I check that when I'm in a layout, page or partial ? (in my case it's in partials).
Thank you and sorry for the noob question, I'm new to october.
Alex
Hi. At the code section of your page you can use BackendAuth facade to check if user is logged or not:
function onStart() {
$user = BackendAuth::getUser();
if ($user) {
...
}
}
https://octobercms.com/docs/cms/themes#php-section
Inside if($user)
statement you can pass anything to the page using array notation:
https://octobercms.com/docs/cms/pages#page-variables
And then on the page check it with {%if ...%}
tag for example:
https://octobercms.com/docs/markup/tag-if
Thank you very much for your fantastic answer ! I would vote for it if we were on stack overflow ^^
troiscent19327 said:
Thank you very much for your fantastic answer ! I would vote for it if we were on stack overflow ^^
No problem, mate:)
1-4 of 4