Skip to main content
7 votes
Accepted

Redirecting after login based on user group

To set the setting dynamically, you’ll need to create a new plugin, which just has an init() method with this: public function init() { // Is this a login request? if ( craft()->...
Brandon Kelly's user avatar
6 votes
Accepted

How to list all User Groups and Users

Something like this should work: {% set userGroups = craft.userGroups.getAllGroups() %} {% if userGroups|length %} {% for userGroup in userGroups %} <h2> {{ userGroup....
Brad Bell's user avatar
  • 67.5k
6 votes

/admin/actions/users/login 404

What server provisioner are you using? Forge? Something else? If it's Forge, it's most likely this: https://twitter.com/nystudio107/status/895726366477344772 Also here are some Nginx configs (with ...
andrew.welch's user avatar
  • 11.6k
6 votes
Accepted

Create a pending user from plugin

Rolling with this does what I need $newUser = new User([ 'firstName' => $submission->firstName->getValue(), 'lastName' => $submission->lastName->getValue(), 'username' => $...
Steven Grant's user avatar
  • 1,855
5 votes
Accepted

Adding second user to user field in plugin brings server to its knees

You've created an endless loop with calling saveEntry within the entries.saveEntry event listener. You can fix it with implementing a static variable. craft()->on('entries.saveEntry', function(...
carlcs's user avatar
  • 36.3k
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 ...
mcclaskiem's user avatar
5 votes

Recovering (or creating a new) admin account

I'm rusty on MySQL so it took me a while to go through this. I'm leaving this here for future internet travelers. It's based on Brad's solution, so read through that first, then you can use these ...
hisnameisjimmy's user avatar
5 votes

Limit number of sessions per user

Im on Craft v3.4.25, and I've added the following event handler in my module to handle this. There are two scenarios here: either you want the new login to invalidate any existing session, or you want ...
Gary Reckard's user avatar
5 votes
Accepted

Automatically subscribe users to MailChimp list?

Install the MailChimp Subscribe plugin and add the following users.onActivateUser event listener to your site’s Business Logic plugin. craft()->on('users.onActivateUser', function(Event $event) { ...
carlcs's user avatar
  • 36.3k
5 votes
Accepted

Single-sign on for multiple Craft sites

No, Craft doesn't have any native notion of SSO. (You can technically run multiple sites from the same Craft instance. If you had sites sharing the same server, you could run them from the same Craft ...
Michael Rog's user avatar
  • 3,420
5 votes

How do I UNLOCK my account?

If you don’t have access to another admin account, you could unlock the account directly in the database. Change the lock value to 0 for the account in the craft_users table.
carlcs's user avatar
  • 36.3k
5 votes
Accepted

/admin/actions/users/login 404

So I looked into this a bunch more tonight to satisfy my curiosity, and here's what is happening. The default rewrite rule that Forge is apparently adding is this: if ($request_uri ~* "^(.*/)index\....
andrew.welch's user avatar
  • 11.6k
5 votes
Accepted

Sending activation emails to all pending users

foreach(\craft\elements\User::find()->status('pending')->all() as $user){ Craft::$app->getUsers()->sendActivationEmail($user); } Fetch all pending users and send them the mail
Robin Schambach's user avatar
5 votes
Accepted

Craft 3 How to get custom user field values

You should be able to access the custom fields on element\user object. Craft::$app->getUser()->getIdentity()->getFieldValue('customfieldname');
Dasun Rathnayake's user avatar
5 votes

Craft 3 How to get custom user field values

If someone lands here searching for a Twig answer like me. {{ currentUser.customFieldHandle }}
Jessica Talzor's user avatar
5 votes
Accepted

Protecting public assets

This answer is a bit self-serving, but I'm the author of the Digital Download plugin. It allows you to control how and when assets are downloaded. You can restrict downloads by a time period, maximum ...
Lindsey D's user avatar
  • 24k
5 votes
Accepted

Not require password on user signup

What you want is the deferPublicRegistrationPassword config setting. By default, Craft will require a 'password' field to be submitted on front-end, public user registrations. Setting this to true ...
Marion Newlevant's user avatar
5 votes
Accepted

Stay on the same page after logout

Yep, postLogoutRedirect can be set to a function instead of a static value. So for example, in your template you can generate a hidden field in your logout form (or append a querystring parameter to ...
Evan Warner's user avatar
4 votes

Craft constantly logging out from admin area

For me the solution required was 'requireMatchingUserAgentForSession' => false in my config/general.php I was debugging the site in Chrome and it was changing my user agent, which was instantly ...
James Nisbet's user avatar
4 votes

Activate Users - privilege

I realise this is an old post but I wrote a plugin to handle exactly this, putting this as an answer instead of a comment since OP asks if there's an override: https://github.com/billythekid/...
billythekid's user avatar
4 votes

Allow user to change or delete their photo for their profile from the front end

FWIW, Niall, I've always just created an additional Profile field for people's images. The weird "not really an asset" aspect of the profile pictures is gone in Craft 3, but I found enough annoyances ...
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Best way to create an entry (bio) view for a User

Not to diminish from Damon's excellent answer — I have certainly used this technique in the past when needed. However, just to provide another option, keep in mind that you don't need to create a ...
Douglas McDonald's user avatar
4 votes

User mysteriously deleted

When a user is deleted from the system via the Craft control panel, they are presented with a model offering them the choice of what they want to do with that user's content. The options are to 1) ...
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

Send activation mail from front end

I'll focus on the "sending an activation email from the front end" part of your question, since that seems to be the crux of it: You'd have to write a very simple, custom plugin. For instant success, ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Delete a relation in frontend form

I believe you're getting that error because you're supplying an array ([]) for the mother field and the only value in that array would be an empty string ("") if they select the There is no mother ...
Stephen Hamilton's user avatar
4 votes
Accepted

Editing entry in front-end

I managed to find a solution, using hidden input fields :) Thank you for all the help :) Edit: Ended up solving this by using tables and saving the username and ID in that. Used a plugin called Super ...
Filip Iversen's user avatar
4 votes
Accepted

Only allow signups from people with @___.com emails

One way of doing this is to write a custom plugin that intercepts the users.onBeforeSaveUser event. You would check that the submitted email address matched your desired pattern and set $event->...
Steve Rowling's user avatar
4 votes

Change email address on front end

Thanks to billythekid's suggestion, adding a password field creates an elevated session, and solves my problem. <input type="password" name="password" placeholder="Password" required> Actually ...
Ian Ebden's user avatar
  • 894
4 votes
Accepted

Validation on username?

I don't know if there is anything natively in Craft to do this, but you could achieve it quite easily with a single file plugin: public function init() { craft()->on('users.onBeforeSaveUser', ...
Alec Ritson's user avatar
  • 4,539
4 votes
Accepted

How to import user addresses?

Addresses are not Elements, so most import plugins will no support them as an import type. You will need to create a plugin or script that imports the addresses into the commerce_addresses table. You ...
Luke Holder's user avatar
  • 6,837

Only top scored, non community-wiki answers of a minimum length are eligible