Manaus Posted June 26, 2014 Posted June 26, 2014 Hello, I have a function trying to print the current user name, but I can't manage to get something. This is my code: function dothing($thepage) { echo $thepage->title; if ($user->isSuperuser()) { // do different } } Tried also function dothing($thepage) { if ($wire->user->isSuperuser()) { // dodo } } But no avail Thanks for any suggestion
sakkoulas Posted June 26, 2014 Posted June 26, 2014 hi Manaus try this function dothing($thepage) { if (wire('user')->isSuperuser()) { echo wire('user')->name; } } dothing(); 1
LostKobrakai Posted June 26, 2014 Posted June 26, 2014 You could pass in the data as parameter. function dothing($thepage, $user) { echo $thepage->title; if ($user->isSuperuser()) { // do different } } dothing($page, $user); hi Manaus try this function dothing($thepage) { if (wire('user')->isSuperuser()) { echo wire('user')->name; } } dothing(); I thought so, too, but "wire('user')->title" returned me NULL in my test. 1
sakkoulas Posted June 26, 2014 Posted June 26, 2014 i don't think that by default field title exist in user template but maybe i'm wrong. you can call id name etc
LostKobrakai Posted June 26, 2014 Posted June 26, 2014 Yeah, I already found that error. I had mistaken your "$thepage->title" and not thought about it more clearly.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now