<p>You could control which fields a user has access to based on their group from a front end edit profile page, but there is no way to do this in the admin outside of creating a plugin with a custom table and screens.</p>

CC BY-SA 3.0
2017-06-19T20:49:12.553Z
I am considering both options. I was digging through the default database to see how Craft relates users to their profile fields, but am having a hard time seeing how they create that relationship. I'm considering creating a custom plugin, but I would want to use crafts built in functionality to relate the users to the table entries. Do you have any knowledge on that?
Paul Kirby
CC BY-SA 3.0
2017-06-19T21:05:41.067Z
When setting up the plugin table you would create a userId field and then you would use foreign key "relationships" in the record to the link the user to the table. I would probably put all the field sin the same table and then just limit what fields the user can edit in UI based on the user's group. Its complicated you'll have to get into the docs and even look up some sample code to get a feel for how to set up a plugin.
Rick Kukiela
CC BY-SA 3.0
2017-06-19T21:07:10.733Z
There is a way to use the field layout stuff with your custom plugin but I dont have  experience with that. There is a 3 part video from a few years ago where they go over it. I would recommend watching that hangout, a few times.
Rick Kukiela
CC BY-SA 3.0
2017-06-19T21:10:21.087Z
https://straightupcraft.com/events/introduction-to-element-types-in-craft-cms-part-1-of-3
Rick Kukiela
CC BY-SA 3.0
2017-06-19T21:12:57.797Z
Thanks a lot! Its sound like what your suggesting in your first comment would essentially be the same thing I would do if I used the included profile fields with craft core, but it would also allow me to hide those specific fields in the CP, which I don't really need. I suppose the easiest route is to just create all necessary fields in the profile, and limit which ones they can submit in the front end based on what type of user they are trying to create.
Paul Kirby
CC BY-SA 3.0
2017-06-19T21:14:13.593Z
No prob glad I could help >:]
Rick Kukiela
CC BY-SA 3.0
2017-06-19T20:35:07.620Z
2017-06-19T20:35:07.620Z
Rick Kukiela
<p>I understand this isn't possible from the Control Panel, I'm developing a custom plugin for this specific client project. Essentially these user groups won't need access to the Control Panelat all, but will have unique permissions within the site and will have a few custom fields. </p>

<p>Can I create custom fields per user group? Or do I just need to create relationships between these fields and the users when they create their profile? Trying to figure out the proper way to go about this.</p>

<p>EDIT:
After watching the Element Type hangout as suggested, they explain why this isn't possible with the current implementation of User Groups, if you are curious.
<a href="https://youtu.be/hU_wduMEimY?t=27m44s" rel="nofollow noreferrer">https://youtu.be/hU_wduMEimY?t=27m44s</a></p>

CC BY-SA 3.0
2017-06-19T19:18:01.707Z
Looking through the hooks documentation it doesn't seem like this functionality is supplied by default... maybe I'm missing something or thinking about this the wrong way.
Paul Kirby
<plugin-development><users><user-profile><craft-pro><user-groups>
How would I create unique fields for different user groups programmatically?
# How would I create unique fields for different user groups programmatically?

(Asked by: username_0 on 2017-06-19)

I understand this isn't possible from the Control Panel, I'm developing a custom plugin for this specific client project. Essentially these user groups won't need access to the Control Panelat all, but will have unique permissions within the site and will have a few custom fields.

Can I create custom fields per user group? Or do I just need to create relationships between these fields and the users when they create their profile? Trying to figure out the proper way to go about this.

EDIT:
After watching the Element Type hangout as suggested, they explain why this isn't possible with the current implementation of User Groups, if you are curious.
<https://youtu.be/hU_wduMEimY?t=27m44s>

**Tags:** plugin-development, users, user-profile, craft-pro, user-groups

> **Comments:**
> **username_0**: Looking through the hooks documentation it doesn't seem like this functionality is supplied by default... maybe I'm missing something or thinking about this the wrong way.  

---

## 1 answers

### Answer by username_1 on 2017-06-19. Score: 1 | Accepted answer

You could control which fields a user has access to based on their group from a front end edit profile page, but there is no way to do this in the admin outside of creating a plugin with a custom table and screens.

> **Comments:**
> **username_0**: I am considering both options. I was digging through the default database to see how Craft relates users to their profile fields, but am having a hard time seeing how they create that relationship. I'm considering creating a custom plugin, but I would want to use crafts built in functionality to relate the users to the table entries. Do you have any knowledge on that?  
> **username_1**: When setting up the plugin table you would create a userId field and then you would use foreign key "relationships" in the record to the link the user to the table. I would probably put all the field sin the same table and then just limit what fields the user can edit in UI based on the user's group. Its complicated you'll have to get into the docs and even look up some sample code to get a feel for how to set up a plugin.  
> **username_1**: There is a way to use the field layout stuff with your custom plugin but I dont have  experience with that. There is a 3 part video from a few years ago where they go over it. I would recommend watching that hangout, a few times.  
> **username_1**: https://straightupcraft.com/events/introduction-to-element-types-in-craft-cms-part-1-of-3  
> **username_0**: Thanks a lot! Its sound like what your suggesting in your first comment would essentially be the same thing I would do if I used the included profile fields with craft core, but it would also allow me to hide those specific fields in the CP, which I don't really need. I suppose the easiest route is to just create all necessary fields in the profile, and limit which ones they can submit in the front end based on what type of user they are trying to create.  
> **username_1**: No prob glad I could help >:]  

---

