Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [usermodel]

The tag has no usage guidance.

1
vote
1answer
25 views

Batch saving a custom field to multiple users via controller

I have to build a custom plugin for an internal user management system/data export that needs to be able to get triggered from the CP. I basically have to sort a big amount of users (1500+) in a ...
1
vote
1answer
66 views

How to pragmatically set registered user status to pending and then manually send activation email

I have 2 front end registration forms. One for normal users and one for admins. In each form I have a hidden input with a group value like so: <input type="hidden" name="group" value="ypo"> In ...
1
vote
1answer
50 views

Adding entry type using setContentFromPost

I'm creating a new user using $user->setContentFromPost(). It all works fine except I can't attach an entry to an Entries field. $user = new UserModel(); $user->username = $email; $user-...
1
vote
2answers
122 views

Saving Custom Field Values to User Profile

I have a custom user field 'myuserfield' How do I save a value to this field via a plugin in Craft3? Here is my current attempt. $myvar = '12345'; Craft::$app->getUser()->getIdentity()...
1
vote
1answer
30 views

Craft redirects to domain.tld/domain.tld/ on logout

I have a logout button on my site that points to the logoutUrl. While the logout works and ends the user session, the user is brought to a page with the URL similar to domain.tld/domain.tld/ where ...
4
votes
2answers
917 views

User events in Craft 3

How do I capture user events in Craft 3? I looked at the documentation but couldn't figure it out. I need to capture after user registration events and after user save events. Here is what I tried, ...
1
vote
1answer
69 views

Save Entry Data as CSV and Email it to the Author / Logged in User

I am trying to email some Entry data that they have created in CSV Format to the author/logged in user. I have a controller setup with a frontend form posting an action to the controller: public ...
1
vote
1answer
91 views

Add Checked Attribute to Custom User Fields on Frontend User Form

I have a multi-select for users to sign up for newsletters. When they edit their profile they need to be able to see which newsletters they are already signed up for. I have the code to output the ...
2
votes
1answer
168 views

Saving/assigning User Group via a plugin

Anyone had experience of assigning a user group when saving or registering a user via a plugin? Tried various combinations of $user->group = 1, $user->group = [1], $user->setGroups([$group]) ...
1
vote
1answer
290 views

Variable for User Field

How do I go about using a dynamic value to access a user field value? I have created a form builder for users and dynamically populate the user field based on the question's associated field. <...
2
votes
1answer
486 views

Correct way of showing errors when editing profile via front-end form?

I've been looking at the following resources: https://craftcms.com/docs/templating/user-profile-form Allow user to change or delete their photo for their profile from the front end Front end edit: ...
0
votes
2answers
105 views

Is there a way to programatically add a user when no one is logged in

In my controller, I can add new users when a user with the right privileges is logged in via craft()->users->saveUser(), but this doesn't work when no user is logged in. Is "users/saveUser" the ...
1
vote
1answer
34 views

How do I set the Post field after manipulation

I'm trying to write a simple plugin that will intercept registration form's data, manipulate it and move it forward. What I'm struggling with is how to set the Post content of a field after the ...
3
votes
0answers
217 views

How can I create a dropdown field programmatically with a plugin?

I'm trying to create a Dropdown field and add it to the User field layout. I've successfully created an empty dropdown field (no options) and added it to the User field layout. Here is my current ...
1
vote
1answer
55 views

Fetching “Pending” Users Related To Entry Within Plugin

This works (but only obtains the active users): // get entry $entry = craft()->entries->getEntryById($entryId); // get existing users in field $entry->customUserField->ids(); So in ...
1
vote
0answers
43 views

Filter conditions on related UserModel in custom Record

My plugin has a custom ResponseRecord with relations to a UserRecord and ElementRecord as follows: public function defineRelations() { return array( 'user' => array(static::BELONGS_TO,...
1
vote
1answer
163 views

currentUser global is null. I can't figure out why

Does anyone know why currentUser would return null? I'm logged in as an admin.. actually the only user. I've cleared cache, logged out and back in, etc. I can't seem to get it to work. I'm trying to ...
2
votes
1answer
97 views

Sharing files with logged-in users

Our client is a builder and they need a way for their contractors to login and upload/download documents about each build (plans, building consents, information etc). They (the builder) also need a ...
2
votes
1answer
115 views

`onBeforeSaveUser` - Access existing user data

I'm trying to run a quick check to see if any of my user's data has changed before saving them. However, I'm running into a situation where I can only access the new data. I can't tell if this is a ...
2
votes
1answer
75 views

onSaveUser event - cannot redirect or access errors

I've written a plugin which intercepts the user.onSaveUser event. However if the save fails the user is still redirected to the page specified in the 'redirect' parameter/field of the form. How do I ...
0
votes
1answer
590 views

Accessing custom fields from User Model

I have a User entries field called 'company'. I'm writing a bespoke plugin to manage users in the front-end and was wondering how I can access the content of this field in my plugin via the user model?...
2
votes
1answer
316 views

How to activate a user in a plugin?

I'm trying to activate a user via a plugin so that when the user is returned to the login page they are re-directed to their profile page. I'm making use of the social logins beta plugin by dukt (I ...
0
votes
1answer
118 views

Trying to capture categories field type data in user profile save/update

I am trying to capture the data that is selected when a user selects categories within a categories field type (handle: groups) within the Control Panel profile tab. I was looking thru the Fields, ...
1
vote
0answers
143 views

Uploading a user picture on registration

I would like to make an image upload field so new members are required to upload a picture. I'm new to Craft (I've been a Drupal Front End developer). Other custom fields are working perfectly, and I'...
1
vote
1answer
128 views

Require password from current user on front-end form?

I have a controller that handles some font-end form validation. From that controller I’d like to require the current (already logged in) user’s password to update any field. How can I do that?
2
votes
1answer
99 views

Conditional for user registration fields

What’s the best way to validate a user registration form to make sure that at least one of two fields is not empty? I’ve tried a very simple controller but can’t get this to work past the point of ...
1
vote
1answer
70 views

entry.getAuthor().getGroups() always return empty array

I'm trying to output users groups for every entries in a for loop, but it returns an empty array: {%for entry in craft.entries.section('news') %} ... {{ dump(entry.getAuthor().getGroups()) }} ...
4
votes
1answer
220 views

How do I set the user password when using saveUser service method?

I am saving users from an external source and able to create them in the Craft db as users. However, each user's password is set to null despite setting it on the user model prior to saving it. Is ...
2
votes
1answer
656 views

How to add addition attribute and fields in public registration form in Craft CMS

User Registration Form I want to setup a public registration form in Craft CMS. Currently this form support only fields username, email, password, but I want to add at least 10 other fields. Also I ...
2
votes
1answer
249 views

Sending email by key to non-user

In a custom plugin, I would like to use Craft's ability to register email message keys in order to keep emails consistent, and I would like to be able to send these emails to users as well as non-...
2
votes
1answer
611 views

Searching for users from a plugin

I know how to find user by username and email. The problem comes when I need to query users based on a custom field. Here is my scenario. I have about 2,000 users (part of a user group 'Affiliates') ...
0
votes
1answer
172 views

How can I return all user custom profile fields in an array?

Hi I'm sure this is simple but it is eluding me. I want to pull out all the user profile fields with twig as an array that I can then check. When I dump the user or currentUser data it does not show ...
2
votes
3answers
1k views

CometChat integration

I need to implement Comet Chat, a facebook-chat-like third-party script, into my Craft project. Comet Chat can connect to most CMS and PHP framework but there is no Craft integration yet, so I tried ...
1
vote
1answer
656 views

Update User Profile with Plugin

I'm trying to create a plugin to create/update users' profile data. I figured out how to create a user but updating... not so much. Here is the code I'm using: $user = craft()->userSession->...
2
votes
1answer
173 views

Processing Business Logic on user.saveUser

I have the following code in my plugin. public function init() { parent::init(); craft()->on('users.saveUser', function(Event $event) { // only fire if new user if ($event->...
1
vote
1answer
265 views

I cannot get the email address to properly update from my user account management form

I figure I must need to pass the current user's password along with the updated email address upon form submit. However, I cannot get the email address change to take. Any help is greatly appreciated. ...
3
votes
1answer
131 views

Remove username from photoUrl path

I just realized that Craft puts the username into the path of the photoUrl. Since I use email addresses as usernames, I don’t think it’s a good idea to expose the email addresses of all users on the ...
1
vote
2answers
890 views

Getting the UID of a user model

I want to use the UID to get a user from a url and don't want to use the ID as it is guessable. I know I can do craft()->users->getUserByUid($uid); but after getting the uid, the uid is not on ...
2
votes
1answer
433 views

RelatedTo with users

The RelatedTo function keeps puzzeling me. I got it working with categories, but now I want to do something in reverse with users. But I don't fully understand the RelatedTo function. I have a ...
3
votes
1answer
115 views

How do I access the properties of an object which triggered an event?

I'm trying my first plug-in; it's to automatically create an entry in a section when a user belonging to a specific user group is activated. However I'm not that hot at PHP and I can't figure out how ...