Jump to content

Default role for different user template


verdeandrea
 Share

Recommended Posts

Hi,

I've followed this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users%C2'> I've created a new template and a new parent page for some kind of user. Everything is working fine, but i would like to have a default role for this kind of user when a new one is created, so the site administrator doesn't have to change it (...and probably mess with it....). 

Is it possible?

Thanks

Link to comment
Share on other sites

  • 10 months later...

hi,

how this works ?

Quote

Hook into Users::added and add the role to those users there.

if i try this:

$this->addHookAfter('Users::added', function($event) {
	wire(log)->save('test', 'Neuer User');
// some code
});

it dosent work nothing in my test.txt, 

but this works:

$this->addHookAfter('Pages::added', function($event) {
	wire(log)->save('test', 'Neue Seite');
	$pages = $event->arguments(0);
	if ($pages->template == 'user'){
		$u = wire(users)->get($pages->id);
		$u->addRole('member');
		$u->language = wire(languages)->get('deutsch');
		$u->save();
	}
});

what ist the way to Hook into Users::added ??

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...