PDA

View Full Version : How to SQL auto add profile field?


Easy5s.net
10-20-2012, 02:14 PM
I want write plugin (SQL cmd) auto add profile field to Profile Field Manager
https://vborg.vbsupport.ru/attachment.php?attachmentid=141874&stc=1&d=1350746031

ForceHSS
10-20-2012, 07:12 PM
INSERT INTO `profilefield` (`profilefieldid`, `profilefieldcategoryid`, `required`, `hidden`, `maxlength`, `size`, `displayorder`, `editable`, `type`, `data`, `height`, `def`, `optional`, `searchable`, `memberlist`, `regex`, `form`, `html`, `perline`) VALUES ('5', '0', '0', '0', '250', '25', '5', '1', 'input', '', '0', '0', '0', '1', '1', '', '0', '0', '0')

This won't put the name in for you. You will need to sort that out yourself at least this is a start for you

Easy5s.net
10-21-2012, 08:33 AM
INSERT INTO `profilefield` (`profilefieldid`, `profilefieldcategoryid`, `required`, `hidden`, `maxlength`, `size`, `displayorder`, `editable`, `type`, `data`, `height`, `def`, `optional`, `searchable`, `memberlist`, `regex`, `form`, `html`, `perline`) VALUES ('5', '0', '0', '0', '250', '25', '5', '1', 'input', '', '0', '0', '0', '1', '1', '', '0', '0', '0')

This won't put the name in for you. You will need to sort that out yourself at least this is a start for you

Please give me an example of how to add profile field "abcd" :)

ForceHSS
10-21-2012, 06:52 PM
maybe you should google the answers before you start this way you will learn more

kh99
10-21-2012, 07:35 PM
The best thing might be to look at the file admincp/profilefield.php, around line 400, the section that starts like this:

// ###################### Start Insert / Update #######################
if ($_POST['do'] == 'update')
{


In a nutshell, it looks like you have to add a row to the profilefield table (sort of like is shown above in ForceHSS's post except the value for profilefieldid should be NULL). Then add a column to the userfield table using the profilefieldid that was generated by the row you inserted (which you can get it by calling $db->insert_id()) to create the column name. Then you need to add two phrases to the phrase table, one for the title and one for the description (also using the profilefieldid to create the names).

Like I mentioned, it's probably best to look at that file. The values for the profilefield table depends on what type the field is, and there's a fetch_query_sql() function that builds the sql from the form parameters, so that might be a little complicated to figure out. But if you're only interested in creating one specific field (like when installing a product), then you could create the field then copy the values from the database (but use NULL in place of the profielfieldid).

I know that was long, but I hope it makes some sense.