Open nesjett opened 5 years ago
A detailed look into userExtendedValidateAll() shows that this line is returning false, so the function does not do its job:
if (($isSignup && (int) $defs['user_extended_struct_applicable'] === (int) e_UC_MEMBER && (int) $defs['user_extended_struct_write'] === (int) e_UC_MEMBER) || (check_class($defs['user_extended_struct_applicable']) && check_class($defs['user_extended_struct_write'])))
I still dont understand it at all, but I guess it's because I'm calling it with the user logged out
There are lots of functionalities related to the EUF in core already so I doubt that you'll need to change the code.
Can you explain the end result that you are trying to achieve?
I just want to modify the value of an user extended field, taking into account its params, for example if its a radio button, it should only accept one of it's configured params.
** EDIT: but I want to do so by the system, without the need of a logged in user
Not sure if I understand you correctly still, but can you not edit that by editing the user in the admin area?
No, I need to edit values programatically, for example, I'm updating the extended user field "gender" when the event user_xup_signup is fired.
This would be perfect:
e107::user($id)->setExtendedFront('gender', 'M => UE_LAN_MALE');
But it checks for the right permissions of the user, this means this cannot be fired when the user is "anonimous"
@nesjett sorry, I didn't read it in detail (it's too complicated) but we used the birthday as mandatory field on signup page and it worked for anonymous too.
Thank you @Jimmi08 , what I'm asking is just for the best way to modify a extended user field WITHOUT an input element.
I'll check the way signup does it anyway, thank you!
I needed this now and this works:
if($result) {
$userThreadId = $result['threadid'];
$ue = new e107_user_extended;
$ue->user_extended_setvalue($aposUserId, 'user_plugin_apos_forum_thread', $userThreadId)ô
}
I've been trying to update extended fields from withing the code and It looks really complex, looking into usersettings.php looks like the proper way of doing so, but I think it could be done in just 2 methods, one for sanitizing and the other for actually inserting the data.
Actually, the way I found to do it, based on usersettings.php is like this:
`$d = ['user_gender'=> $genderize->gender];
`
Althought, this line:
//$euVals = $ue->userExtendedValidateAll($euVals, []); // Validate the extended user fields
Is used in usersettings.php but I can't get it to work so I had to put results by hand, without other checks with this line:$eufVals['data']['user_gender'] = $tp->toDB($euVals['user_gender']);
Really there is no other way of setting user extended fields?