Jump to content

print user from function


Manaus
 Share

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...