Jump to content

Custom users setup questions

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.

Share this post

Link to post
Share on other sites


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.

Share this post

Link to post
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".

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By VeiJari
      Hi, this is the first we are trying to make a page that has only one type of user that has access to every page. 
      The other users should only have a given access to specific pages, not to the whole template.
      My structure
      -Field -Organisation -Project -Report I want that the "measurer" role only has access to "project x" and it's children, but no view access to every project, organisation or field. I've tried to do this with https://modules.processwire.com/modules/page-edit-per-user/ but it still needs a view access to the whole tree to see the "project x" page. Or is there something I haven't figured out?
      Maybe I have to make it via the API: a select field in the "organisation" template where the admins could add the users and then I use hook to update the privileges?
      Have you done something like this and how did you accomplish it?
      Any help would be appreciated.
    • By Pip
      Hi everyone!
      I'm trying out the Login/Register module for my site. Noted that the module assigns the newly registered user to login-register role. 
      Once you modify the login-register role's permissions, particularly adding page-edit, the new member role will be set to guest. 
      Thing is I'd like to grant my new users the power to create their own pages. Any advice? 
    • By Greg Lumley
      Hi! I've just discovered Processwire and I'm absolutely loving how clean it is. Especially with the full control over what it outputs. 
      Excuse me if this is a really stupid question.
      What happens if a user wants to insert multiple images into the blog field? In other words Shift+Click all the images attached to a specific page in and insert. It seems I can insert one at a time but not multiple.

      Based on the above, I want to rebuild my website. I'm a photographer (ex php dev 2004) and plan also to target websites at other photographers. So inserting multiple images into blog posts is a key part. I'd like to output that to something like UIkit or some kind of Masonry Gallery script. Any thoughts would be fantastic please. 
      Thank you.
      I'm an ex PHP developer now photographer, now thanks to Corona and not photo work, a rusty PHP developer 😁
    • By AndZyk
      this maybe a simple question, but it bothers me for a while now:
      There used to be a warning, if two or more user try to edit the same page. But ever since AdminThemeUIkit I haven't seen it any more.
      Is this a bug or are there special circumstances under which the warning will be displayed?
      If I am logged-in in the same browser with one default and one privat window, I don't see this warning. But also different browsers on different machines in the same network don't see this warning.
      I was looking for the blog post on which this feature was announced, but couldn't find it anymore.
      We had the case, that two people were writing a text for the same page, but after person A saved the page first, the text of the person B was lost. I know we could have used ProDrafts for this case, but it shouldn't happen in the first place.
      I would appreciate some feedback. 😀
      Regards, Andreas
    • By pwFoo
      I try to add page-edit-own and page-delete-own permissions, but it's strange...
      If a add the custom permissions it looks like both are children of page-edit respectively page-delete. I played with added / revoked permissions, but I can't get it work, that a user of a role just can delete own content.
      First the user can't delete any content and now the user can delete own and foreign pages 🤪
      Is there a tutorial to learn more about the PW permissions?
      Or do I have to rename the permissions to page-own-edit and page-own-delete to be independent from page-edit and page-delete?
  • Create New...