16

Before you can allow a user to manage their profile photo in your front-end profile edit form, be sure to update your form tag with the enctype="multipart/form-data" parameter: <form method="post" enctype="multipart/form-data"> You can access a users profile photo using the currentUser global and fallback to a different image like so: {% if ...


15

I found the answer on the Craft website under the UserModel section: getPhotoUrl( size ) Returns a URL to the user’s photo at a given size in pixels (defaults to 100). You can also pass in "original" if you want to get a non-resized photo back. Although this does answer my question, I feel the behavior between handling this "asset" compared to an ...


12

After taking a look at this it would seem like the lightswitch is always expecting a value to determine the whether the state should be on or off. When you don’t check the input and submit the form, the field doesn’t get sent to the controller, the value isn’t replaced (as there technically is no value) and nothing updates. You can work around this by ...


10

If you want a user to be able to upload a profile photo from the front-end, the you should be able to add enctype="multipart/form-data" to your form that saves your user and have a file input called 'userPhoto'. <input type="file" name="userPhoto" id="image-upload" /> If you want to delete a user's existing profile photo, then add a hidden input ...


9

Unlike Vue Resourse (if you've used it), Axios does not have a good way to emulateJSON on legacy servers or frameworks that do not understand submissions sent as application/json. Your data gets to Craft but it is not understood, leaving POST empty. You would need to have Axios submit to your own controller, where you can read the raw data, JSON decode it, ...


7

user and currentUser are exactly the same. They contain the UserModel of the currently logged in user. Why are they exactly the same? Originally, user was the preset value for the current user. However, there were many cases of people manually setting a value for user (often in the context of a for loop through a group of users), and therefore overwriting ...


7

firstName, lastName, and email are actual user fields (not custom), so their name= attributes shouldn’t have the fields[] namespace. <input type="email" class="form-control" id="email" name="email" value="{{ user.email }}"> <input type="text" class="form-control" id="firstName" name="firstName" value="{{ user.firstName }}"> <input type="...


6

Currently it has no affect on the Lightswitch field at all, which I think is the right call. However, you do have a valid use-case for either making a setting on the field that forced it to be "on" if required is set or maybe even a separate "Require On" field type all-together. Regardless, probably worth putting up on http://feedback.buildwithcraft.com


5

User registration works just like front-end entry editing. You build the form on any page you like, and submit it to the action "users/saveUser". All fields need to be coded by you, and extra profile fields can be filled in by setting the input name to "fields[handle]". The Craft Documentation has an example registration form. The also have an example for ...


5

Based on Brad's response I created the following controller in a plugin: <?php namespace Craft; class Myplugin_SaveUserController extends BaseController { protected $allowAnonymous = true; /** * Handle the save user form request. */ public function actionSaveUser() { $this->requirePostRequest(); $email = ...


4

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 in Craft 2.x that I just started using a custom field instead. Now the downside is you don't get a nice picture of them in the backend, but the cases where I'...


4

You could add a custom asset field for the users' profile images and hide the default one in the CP. Here's a plugin to do this: Control Panel CSS by Lindsey D


4

You could add a custom asset field for the users' profile images and hide the default one in the CP. Here's a plugin to do this: Control Panel CSS by Lindsey D


4

Marcus, I think you can use anything as an url for a user's page. In your case, I'd make a dynamic route like: user/* and assign it a template, for instance: user/_entry Within that template, all you'd have to do is lookup the user by the match found in the url. The variable matches contains the first-last part (the * part of your route). With that, the ...


4

You use setContentFromPost method on the UserModel if you are posting to your plugin, like so (this is what happens when you save your profile in the control panel): $user->setContentFromPost('fields'); There is also a setContent method, which takes a ContentModel or an array: $user->setContent([ 'fields' => ['field1' => 'value'] ]) Behind ...


4

OK, just did a quick look through the docs. Appears that this can be set via the config file. Link to documentation There's also the option to set whether the user is logged in automatically.


4

While both lightswitches and checkboxes represent an on/off state, they are quite different. Standard browser behavior is designed to only post checkbox data if the checkbox is checked, otherwise it is ignored. In PHP, when processing the form, you would want to check whether the post-data is present or not; if it's present then the value is checked; ...


4

When I use my email field to attempt an email address change, I get a verification email generated by Craft sent to the new email address, but the email change is not reflected in either the CP or on the front-end when I refresh the form. The user's email address won't actually update until you click the link in the verification email the user receives.


4

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 version will allow you to have public registration on our site. Here is more information about users and user groups. To add additional fields to your registration ...


4

In Craft when changing an email address (even if it's the currently logged in user), they must supply their existing password as well. You can use the hidden redirect input to send to whatever template you want (assuming saving the user was successful). In your case, then template can tell them to check their email and click the link it contains. <form ...


4

When saving an entry field type as part of your plug-in it needs to be an array of IDs in order to work correctly. This can either be handled via a plug-in or in the form by passing the value as an array to that field handle. Plug-in: $user->setContentFromPost(array( 'entryField' => array(10) )); $success = craft()->users->saveUser($user); ...


4

Not possible – any input values added to your profile editing form (such as test in your case) will be included in the POST request to the users/saveUser controller action, but they won't actually be included in the redirect request back to the page (or to whatever URL is in your form's hidden redirect input). As a workaround you can always check for the ...


4

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 option. So what Craft is attempting to save as a relation is [""]. Instead of an array of integer ID numbers, it's getting an empty string which isn't a valid ...


4

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 I don't think it's that intrusive, and it's a good security step that should generally be encouraged when making any profile edits.


4

We achieve this by simply checking the ids of the addresses set on the cart. Commerce saves the last used shipping and billing address for customers, so you can just use some simple template logic to achieve what you want I think: {% set sameAddress = true %} {% if cart.shippingAddress and cart.billingAddress %} {% if cart....


3

You can write a plugin that has a Template Variable that exposes Craft's SystemSettingsService->getSettings() method like so: public function isPublicRegistrationEnabled() { return craft()->systemSettings->getSetting('users', 'allowPublicRegistration'); } You'd call it from the template via: {% if craft.myAwesomePlugin....


3

Currently the users/saveUser (and the deprecated users/setPassword) controller action doesn’t support Ajax requests, so there won’t really be an easy way to tell if it worked or not. If you really want to update user passwords over Ajax, your best bet will be to write a plugin with its own custom controller action, which mimics the password-related stuff in ...


3

It should also be noted that to change your password or email, the current password has to be passed along with the request. // You must pass your current password to change these fields for an existing user


3

Maybe not the answer you are looking for, but I asked a similar question. I needed to grab the original size of the user uploaded images. Change the size of a users profile photo? You can just use getPhotoUrl('original') when calling the images on the front end. This doesn't give you an 'untouched' version of the image but Craft stores the original and ...


3

There isn't anything to do this out-of-the-box in Craft. I believe the proper way you'd want to approach it would be to write a plugin that has it's own field type that takes into account user permissions. An admin would get a normal text input, for example, and any other user would just see read-only text.


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