?
avatar stutteringp0et
stutteringp0et
5 Sep 2017

Steps to reproduce the issue

  1. Create some custom user fields in Users>Fields
  2. Within a user plugin, call JUserHelper::addUserToGroup($uid,$gid) inside of the onUserAfterSave method
  3. Edit and save the user

Expected result

Groups change, field values remain

Actual result

groups change, field values are defaulted

System information (as much as possible)

J3.7.5

Additional comments

I created a CLI to test this and it works as expected. This only seems to happen if I add or remove groups within a user onUserAfterSave event

My temporary solution is to not use JUserHelper to add or remove groups, instead I'm querying the table directly to make my changes. I would rather not do this, but it keeps me moving forward:

	$db->setQuery('DELETE FROM #__user_usergroup_map WHERE user_id = '.$id.' AND group_id IN ('.implode(',',$removegroups).')');
	$db->execute();
	
	if(!in_array($addid,$user->groups)) {
	    $o = new stdClass();
	    $o->user_id = $id;
	    $o->group_id = $addid;
	    $db->insertObject('#__user_usergroup_map',$o);
	}
avatar stutteringp0et stutteringp0et - open - 5 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 Sep 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Sep 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Sep 2017
Category com_fields
avatar stutteringp0et stutteringp0et - change - 5 Sep 2017
The description was changed
avatar stutteringp0et stutteringp0et - edited - 5 Sep 2017
avatar stutteringp0et stutteringp0et - change - 5 Sep 2017
The description was changed
avatar stutteringp0et stutteringp0et - edited - 5 Sep 2017
avatar stutteringp0et stutteringp0et - change - 5 Sep 2017
The description was changed
avatar stutteringp0et stutteringp0et - edited - 5 Sep 2017
avatar Denitz
Denitz - comment - 20 Sep 2017

Duplicate, see #17801 and #17837

avatar joomla-cms-bot joomla-cms-bot - change - 20 Sep 2017
Status Duplicate Report Closed
Closed_Date 2017-09-20 18:22:14 2017-09-20 18:22:15
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 20 Sep 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Sep 2017
Status New Duplicate Report
Closed_Date 0000-00-00 00:00:00 2017-09-20 18:22:14
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 20 Sep 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Sep 2017

closed as duplicate Report. Thanks for Hint @Denitz


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17878.

avatar stutteringp0et
stutteringp0et - comment - 20 Sep 2017

Thanks @Denitz, I'll keep an eye on 17878

Add a Comment

Login with GitHub to post a comment