Jump to content

Create custom fields programatically


whmguy

Recommended Posts

I have created a server module and placed it in

/server/modules/mymodule, it shows up and works great!

 

Now I need to have some custom fields created automatically (programatically)

when the module is used for the first time. How can I do that?

 

I assume you mean custom fields for a clients?

there is no way to do it via API or some built-in instrument

I researched the way whmcs inserts custom fields into DB:

they are stored in tblcustomfields table

and to insert a record via PHP you just need to run SQL code something like this:

 

INSERT INTO `tblcustomfields` (`type`, `relid`, `fieldname`, `fieldtype`, `description`, `fieldoptions`, `regexpr`, `adminonly`, `required`, `showorder`, `showinvoice`, `sortorder`) VALUES
('client', 0, 'Customer field name', 'tickbox', 'Customer field description', '', '', '', '', 'on', '', 0);

Link to comment
Share on other sites

Still haven't found a way to do this.

Also: how can I update the values of those customfields from my code? Is there a way to save data to them?

 

If not, how are people storing extra data for addon services? creating a table and storing there? if so, where is the best place to create a table? In $mymodule_ConfigOptions() ?

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated