Manaus Posted June 26, 2014 Share 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 Link to comment Share on other sites More sharing options...
sakkoulas Posted June 26, 2014 Share Posted June 26, 2014 hi Manaus try this function dothing($thepage) { if (wire('user')->isSuperuser()) { echo wire('user')->name; } } dothing(); 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted June 26, 2014 Share 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 Link to comment Share on other sites More sharing options...
sakkoulas Posted June 26, 2014 Share 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 Link to comment Share on other sites More sharing options...
LostKobrakai Posted June 26, 2014 Share Posted June 26, 2014 Yeah, I already found that error. I had mistaken your "$thepage->title" and not thought about it more clearly. Link to comment Share on other sites More sharing options...
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