Hey all,
I am working on a plugin that requires interaction with the database. What I want to do is to programatically add custom profile fields by adding records to the "user_info_field" table in the database, which I successfully do by doing
$DB->insert_record('user_info_field', $polje);
,where $polje is the object with all the data to add to table columns. My problems start when I try to access the id of the inserted record which is returned by the function which I verified by doing
$polje->id = $DB->insert_record('user_info_field', $polje);
echo $OUTPUT->notification($polje->id);
, which works just fine. However, I can't assign the returnet id nither to an array (which is the ultimate goal), neithe to a normal variable. I have also tried to do
$polje->id = $DB->insert_record('user_info_field', $polje);
$id = $polje->id
, but whatever I do, I get the error "Fatal error: Can't use function return value in write context".
This error is driving me nuts. I have searched the web for answers but all I have found is a lot of answers that this is some weird error which occured in PHP versions before PHP 5.5, which I am definetely not using.
If it helps, I am using Moodle 3.11.6+ (Build: 20220405) with PHP 7.4.29, running on an XAMPP server,
Can someone please help me with that?
Vid