Jump to content

Custom users setup questions


hellomoto
 Share

Recommended Posts

In addition to a site administrator I need two special types of users, teachers and students. I was simply adding their profile fields to the default user template, but could not seem to set visibility by role for certain fields that were only applicable for the teacher template. I tried role=teacher, page.role=teacher, etc... The test field wouldn't show, so I instead went ahead and set the userTemplateIDs and usersPageIDs in config.php to

$config->userTemplateIDs = array(3, 50, 51); // default, student, teacher
$config->usersPageIDs = array(29, 1023, 1024); // default, student, teacher

-- the above IDs belonging to existing templates and parent pages, of course. But now when I go to the Users page at /processwire/access/users/ I get this:

Fatal error: Call to a member function has() on a non-object in /wire/core/Users.php on line 68

That line is

		if(!$roles->has("id=$guestID")) $page->get('roles')->add($this->wire('roles')->getGuestRole());

and I don't see the problem there. When I comment it out, I can access the page, and see that my test teacher user indeed has no role, maybe that's throwing the error (although I'm not logged in as him). How do I set the respective roles for these new user templates?

What else do I need to do to have these properly set up? I assumed the username would be the page name by default so it's got that and the necessary title, email, password, plus some extra fields. Any tips? I'm using v2.6.15 dev. Thanks.

Link to comment
Share on other sites

Hi!

You mention that you set the config values to the IDs of existing templates for teachers and students. I think this is where the problem is - if your user templates don't have the necessary fields that the default users do, then that could be an issue.

The instructions recommend cloning the user template to start these off, presumably so that your custom users have everything they need before you start customising.

What I would try first, is to edit your teacher and student templates and import the fields used on the user template - this should pull in password, email and roles (I think).

If that doesn't work, I would rename your existing teacher and member templates to something else (to use as a reference), follow the instructions exactly, and see if that works. If it does, go ahead and configure them the same as the ones you renamed - import fields, change access/family properties etc.

Link to comment
Share on other sites

I was simply adding their profile fields to the default user template, but could not seem to set visibility by role for certain fields that were only applicable for the teacher template. I tried role=teacher, page.role=teacher, etc...

You need to use the id, to make it work, e.g. "roles=1024".

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