Jump to content

Get admin user email address


tinacious
 Share

Recommended Posts

It depends on what admin user you want to grab, as you'd need to refer to them by name. But assuming the name is 'admin', you'd do this to send them an email:

$admin = $users->get('admin');
mail($admin->email, 'Hi Admin!', 'This is a test'); 


You might also notice this in /site/config.php:

/**
 * adminEmail: address to send optional fatal error notifications to.
 *
 */
$config->adminEmail = '';

If that is defined, you could use that for your purpose as well. 

  • Like 1
Link to comment
Share on other sites

It depends on what admin user you want to grab, as you'd need to refer to them by name. But assuming the name is 'admin', you'd do this to send them an email:
$admin = $users->get('admin');
mail($admin->email, 'Hi Admin!', 'This is a test'); 

You might also notice this in /site/config.php:

/**
 * adminEmail: address to send optional fatal error notifications to.
 *
 */
$config->adminEmail = '';

If that is defined, you could use that for your purpose as well. 

Thanks Ryan, both of these options are great. Thanks!

  • Like 1
Link to comment
Share on other sites

  • 7 years later...

@modifiedcontent you can do $users->find("roles=superuser");

22 minutes ago, modifiedcontent said:

Get the first superuser?

$users->find("roles=superuser")->first;

22 minutes ago, modifiedcontent said:

can there be more than one superuser?

yes, PW doesn't limit the number of superusers to just one single user.

  • Thanks 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

×
×
  • Create New...