12
votes
Accepted
What are the options for taking membership subscriptions via Craft?
I don't think that there currently is a plugin option right now, but keep an eye on the craft plugin page. However, given your requirement to "automatically assign users to different membership groups"...
9
votes
Is there a way to detect if a action is triggered from a control panel form?
If anyone comes here looking for this answer for Craft 3 the function you are looking for is Craft::$app->getRequest()->getIsCpRequest()
9
votes
Show content if logged in user is in userGroup1 OR userGroup2?
According to the docs, the userModel.isInGroup() method takes a "user group model, its handle, or ID" – in other words, it can only test for membership in a single group, not several.
What you want ...
7
votes
Automatically assign a user group
Under Settings > Users > Settings Tab there is an option to allow public registration and Default User Group with a drop down that lets you select a user group.
If you need more flexibility, you ...
7
votes
How do you set a user's group on a registration form?
If you're looking for a Craft 3 solution, I just got this set up on a project and hope it helps someone else out.
First you'll need to add a custom field to your form. If you want your user to ...
6
votes
Accepted
Craft 2.3 new User does not set the default permissions group
The setting still works, but keep in mind that for it to take effect, A) you have to be registering a user through a custom registration form on the front end, and B) you have to be logged out. ...
6
votes
Accepted
Is there a way to detect if a action is triggered from a control panel form?
Yes there is, craft()->request->isCpRequest() returns whether the request is from the CP or not.
6
votes
Accepted
Show content if logged in user is in userGroup1 OR userGroup2?
Going to chime in here as I ran into a similar issue, and solved it a bit differently.
Instead of using group handles I was using a dynamic set of Group IDs. However, the problem still remains that ...
5
votes
How can i check an entry author's user group?
As Fabio pointed out, i'd managed to miss the isInGroup method. Slightly embarrassing!
So for anyone else looking to do what i asked, i changed my code to the following:
{% if entry.author.isInGroup(...
5
votes
How to add addition attribute and fields in public registration form in Craft CMS
Before you can allow any type of user groups you will need at a minimum of the Client version of Craft. To allow public registration, you will need the Professional version. Only the Professional ...
5
votes
Accepted
Entry validation not working when Publish live changes permission is not checked
As carlcs said, this is already working as expected. Craft only enforces content validation rules for enabled entries (not including drafts), and most people prefer that behavior.
If you want to ...
5
votes
Accepted
Eager Loading Users Returning "Array to String Conversion" Error
Just checked eager-loading a text field in a template and by eager-loading it you are actually converting the field to an array and therefore unable to template it as usual. Eager-loading is generally ...
4
votes
How do you set a user's group on a registration form?
This answer was originally written for Craft 2. For a Craft 3 solution, see Ryan's answer above.
I literally just worked through this problem last week. Ran into the same issue, so I reached out to P&...
4
votes
Accepted
How to remove a user from a user group?
assignUserToGroups has $groupIds parameter (int / array) preset to null. From the docs:
assignUserToGroups($userId, $groupIds = null)
So calling the function without that parameter set should do ...
4
votes
Accepted
Could I use categories for users instead of user groups?
If the users will never have access to the Craft CP then you can use categories or any other applicable field type (i.e. dropdown, radio buttons, tags, etc.) to create differentiation between the ...
4
votes
Accepted
Creating Custom User Permissions
You can create a plugin that adds custom user permissions via the registerUserPermissions hook.
4
votes
Accepted
Change User Group Front-End
You'd need to do this from a plugin that has a controller that calls UserGroupsService->assignUserToGroups().
4
votes
Accepted
Restricted access to assets in Redactor
There is no native way to limit which sources appear in the asset window. I imagine it can be accomplished with a custom field type. This would be a great feature for future releases; I recommend ...
4
votes
Accepted
Get Groups from User in plugin
Your code to get a user returns a UserModel (as can be seen from the Full Class Reference docs):
$user = craft()->users->getUserById($id);
You can then get the user groups the $user is a ...
4
votes
Entry validation not working when Publish live changes permission is not checked
As other answers have touched on, the behaviour you're seeing is by design.
I've written a plugin called Always Validate which will make Craft validate all disabled entries and categories – including ...
4
votes
Accepted
Registration into default group is not working as expected
I get bit by this a lot.
Just like @Stephen Lewis suggested - make sure you are not logged into the same browser.
For example, log into the CP with Safari (or whatever) and then use Chrome to ...
4
votes
Accepted
Is there a way for a user to assign another user to a group on the frontend?
Assuming you're using the core users/save-user action to edit users (as per the official User Profile form example) you can add a form input named groups to save group assignments from the frontend ...
3
votes
Automatically assign a user group
To have a new user automatically assigned to a user group, there are two easy ways to do it.
(1) If the user registers through a front-end form:
You can pre-set their user group by going to Settings ...
3
votes
How can I select users that are not members of any user groups?
You could get the IDs of all users belonging to a group, and use these IDs prefixed with not as the id parameter in a second craft.users ElementCriteriaModel:
{% set userIds = craft.users.group('...
3
votes
Restricting access to fields based on user group
You can use the Control Panel User Group plugin to automatically add special classes to the <body> tag in the CP.
Once those classes are in place, it's easy to use CSS or JavaScript to hide ...
3
votes
Accepted
How can I get a user to choose in which group he registers using the User Registration Form
As far as I know there is no way to do this without a plugin. However, developing a plugin for this is not difficult. In your form you would want to add an additional drop-down, multi-select, or ...
3
votes
Entry validation not working when Publish live changes permission is not checked
That's the idea behind Drafts, to store entries not yet ready to publish, unfinished ones so to speak.
I think it does make sense to not validate the fields. Good feature!
3
votes
Saving/assigning User Group via a plugin
So it seems the only way to achieve this is to assign the user to the group, not the other way round (assign the group to the user).
So once my user has saved I can call following:
craft()->...
3
votes
User restricted access to content via a common template
I assume you have basic knowledge in creating plugins, if not I suggest visiting the docs.
It's actually pretty easy to achieve your goal.
Create a Plugin and store an array of permission's in it's ...
3
votes
Accepted
Set UserGroups for existing User
You can assign a user to certain groups via
Craft::$app->getUsers()->assignUserToGroups($user->id, [1,2,3]);
Would assign them to the groups with the ids 1, 2 and 3
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
user-groups × 75users × 34
plugin-development × 11
permissions × 10
craft3 × 7
registration × 5
templating × 4
control-panel × 4
craft-pro × 3
usermodel × 3
current-user × 3
assets × 2
entry × 2
form × 2
field × 2
emails × 2
login × 2
user-profile × 2
frontend-form × 2
group × 2
entries × 1
plugin-craftcommerce × 1
categories × 1
localization × 1
database × 1