Public Ticket #3649722
Insert data via PHP


  • Jonny Vaughan started the conversation


    We are looking at easy ways to insert (and delete) data within a wpDataTable via PHP.

    Our use case is this:

    Frontend users will be able to submit a CSV file via a form. That submission needs to be reviewed by an admin user before the data is then inserted into the wpDataTable that we have set up. We are happy to create the form ourselves and manage the approval part. When the submission is approved we want to use a simple PHP function to insert the data (without having to set up our own SQL connection to the external database that we're using). 

    Does that exist within a class somewhere in the plugin? Or at least the ability to retrieve a database connection, then we run the SQL against that ourselves?

    Best wishes


  •  2,529
    Aleksandar replied

    Hello Jonny.

    Thank you for reaching out to us.

    Something like this can't be achieved with wpDataTables' built-in features, so it's considered a custom solution, which is not covered by our support.

    Updating of table's data is covered only for manual tables. For the separate DB connection, you can check out this class: wp-content/plugins/wpdatatables/source/class.connection.php

    You can also take a look at the method addDataSourceToTable in the file wp-content/plugins/wpdatatables/source/class.wdtconfigcontroller.php, around line 1816 and adjust it.

    This is just advice since, as I mentioned above, we don't provide customization services. You can also take a look at our filtershooks, and front-end table callbacks.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables