Title: Database Table add content
Last modified: February 13, 2021

---

# Database Table add content

 *  [mohamed_bo](https://wordpress.org/support/users/mohamed_bo/)
 * (@mohamed_bo)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/)
 * Hi for all,
    I manage a website where there is possibilities to book tours. we
   are a group of guides that we create our own platform between us. All work fine
   but now I have a difficult task to do, some guides want to disable some dates,
   in backend is possible and easy, but we don’t want to do it with backend, only
   by frontend giving to each guide a password to limit access. what we want is:
   For each tour we want a kind of form with only 1 field: Date to disable. Let 
   take an example of tour with ID 277 (Let call it TOUR IN AMSTERDAM), so the form
   will have the possibility to add data only with tis ID. In the Databae access
   to table wp_postmeta there is the post_id with value 277 (A lot of row of course)
   meta_key with a value wt_disabledate (The condition or the the rows with date
   to disable) meta_value with the date to disable booking, but here the format 
   in the database is LONGTEXT and the date is saved in Unix date format (for example
   28/02/2021=1614470400), guide have to introduce the date in normal format and
   system have to add a row with all data converting the last one to UNIX DATE FORMAT.
   Can anyone help us with some idea? Plugin? or what else? We are without work 
   1 year now because of pandemic and we are trying to get ready after this pandemic
   to come back to earn some money. Thanks to all.
    -  This topic was modified 5 years, 3 months ago by [mohamed_bo](https://wordpress.org/support/users/mohamed_bo/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/#post-14045980)
 * How you’d disable certain dates needs to be integrated into whatever booking 
   system you are using. You say it’s easily done in the backend, so the functionality
   already exists, you just need to somehow implement it on the front end. Guides
   need to be logged in to be able to make changes. You could implement a front 
   end Ajax login feature, or just link to the normal login page with a “redirect_to”
   query string to return the user to the current page after login.
 * The front end form should be configured to mimic whatever backend request causes
   dates to be disabled. You can use your browser’s network developer tool to see
   what a normal backend request looks like. The request likely includes a security
   nonce. You’ll need to dig into the plugin source code to see how it creates its
   nonce so you can use the same method.
 *  Thread Starter [mohamed_bo](https://wordpress.org/support/users/mohamed_bo/)
 * (@mohamed_bo)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/#post-14047204)
 * We can’t do it by the backend due that the field that manage the date to disable
   are show only in Admin user.
    Let say that what we want is in 2 steps: 1- Simple
   input of the date in normal format in the table. If the convert is possible here
   to UNIX DATE than perfect. 2- Convert the date by SQL consult Without touch the
   code of plugin or anything else. Thank you
 *  Thread Starter [mohamed_bo](https://wordpress.org/support/users/mohamed_bo/)
 * (@mohamed_bo)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/#post-14047369)
 * I make a temporary solution for moment and it work.
    To add row with date in 
   correct format (UNIX DATE) to the table I use CSV file to import in MyphpAdmin,
   it mean that guides just have to send the file. To delete dates that they need
   to enable I am using a plugin WPDataTables. But still temporary due that isn’t
   auto update for CSV uploading.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/#post-14048512)
 * I’ve run into that admin only issue with other plugins. Plugin authors could 
   do a better job of providing some way to alter the user capability required to
   do certain things. A filter hook would suffice.
 * If you know the correct DB entry needed to do this, you could use the global `
   $wpdb` object’s `insert()` method to add it. You need a front end form to collect
   the required data. You could implement some sort of date picker element to help
   ensure the date format provided is consistent. N.B: The HTML5 date input field
   is not supported by Safari. Find a JavaScript based cross browser compatible 
   equivalent.
 * You then need some form handler code to process form data and to insert it into
   the DB. The form and handler code could all be contained on a custom page template.
   Be sure your form handler uses the usual security measures: verify a nonce, verify
   the user has proper role and capability to do this, sanitize and validate the
   incoming data.
 * The PHP function `strtotime()` is pretty good at interpreting any typical date
   format into a UNIX timestamp. With the timestamp you can use `date()` to format
   the date exactly as you wish.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Database Table add content’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [form](https://wordpress.org/support/topic-tag/form/)
 * [tables](https://wordpress.org/support/topic-tag/tables/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/database-table-add-content/#post-14048512)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
