Editing User Custom Fields

Report issues with Enuuk Auction Platform or Mods here - remember to raise a ticket with phpauction.net as well
Post Reply
RWAP
Site Admin
Posts: 745
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Editing User Custom Fields

Post by RWAP » Tue Aug 22, 2017 12:57 pm

There is a bug in the way custom fields in a user's profile are processed, meaning they don't work if you have more than one custom field (and in particular, the user cannot delete the whole information if it is not a mandatory field).

In class\User.php
Find:

Code: Select all

                if (count($this->customFields)) {
                    $sql = 'delete from '.CustomField::DB_USER_FIELD_TABLE.' where userId="'.$this->id.'"';
                    $DB->query($sql);

                    $sql = 'insert into '.CustomField::DB_USER_FIELD_TABLE
                        .' (userFieldId, userId, value) values (:fieldId, :id, :value)';
                    $query = $DB->prepare($sql);
                    foreach ($this->customFields as $k => $v) {
                        $query->execute(array(':fieldId' => $k, ':id' => $this->id, ':value' => $v));
                    }
                    unset($query);
                }
Change this to:

Code: Select all

                $sql = 'delete from '.CustomField::DB_USER_FIELD_TABLE.' where userId="'.$this->id.'"';
                $DB->query($sql);
                if (count($this->customFields)) {
                    $sql = 'insert into '.CustomField::DB_USER_FIELD_TABLE
                        .' (userFieldId, userId, value) values (:fieldId, :id, :value)';
                    $query = $DB->prepare($sql);
                    foreach ($this->customFields as $k => $v) {
                        $query->execute(array(':fieldId' => $k, ':id' => $this->id, ':value' => $v));
                    }
                    unset($query);
                }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest