Shortcode Basics

December 15th, 2016

Shortcode Basics

The following shortcodes are provided:

  • [cfdb-datatable]
  • [cfdb-table]
  • [cfdb-json]
  • [cfdb-value]
  • [cfdb-count]
  • [cfdb-html]

All of these shortcodes provide a set of common options, so they are documented here. We will use [cfdb-table] in our examples, but understand it applies to all shortcodes.

Simplest Shortcode Example

You have a form named “myform” and you want to display all its rows and columns in a page or post:

  • [cfdb-table form="your-form"]

This shows the whole table with CSS provided by the plugin. See the page on [cfdb-table] to learn more about how to apply your own styles.

Choosing which Columns to Display with “show” and “hide”

  • [cfdb-table form="myform" show="field1,field2,field3"] (optionally show selected fields)
  • [cfdb-table form="myform" hide="field1,field2,field3"] (optionally hide selected fields)
  • [cfdb-table form="your-form" show="f1,f2,f3" hide="f1"] (hide trumps show, f1 will be hidden)

As of version 1.8, “show” and “hide” now support regular expressions to be able to specify column names. Regular expression match according to preg-match.

Examples:

  • [cfdb-table form="myform" show="/.*name/"] (shows all fields whose name ends with “name” such as “first-name” and “last-name”)
  • [cfdb-table form="myform" show="/.*name/i"] (Same as previous, but is a case-insensitive match. So “Last-Name” as well as “last-name” match)
  • [cfdb-table form="myform" hide="/Submitted.*/"] (Don’t show fields starting with “Submitted”)
  • [cfdb-table form="myform" hide="message,/Submitted.*/,/Cookie.*/"] (Don’t show (1) the “message” field, (2)  fields starting with “Submitted”, (3) fields starting with “Cookie”. If you have the option on to capture users’ Cookies with their form submissions, use hide=”/Cookie.*/” to hide them. )
  • Remember that is you have both “show” and “hide” specified, any field that match both will be hidden. That is, “hide” trumps “show”.

Adding Security With “role”

(As of version 2.4.1) The “role” attribute can limit the short code to only create output for logged-in users with a minimal user role. Set the “role” attribute to one of:

  • Administrator
  • Editor
  • Author
  • Contributor
  • Subscriber
  • Anyone

Example: if role="Editor" is used, then a user logged in with role Author, Contributor or Subscriber sees no output. A user logged in who has role Editor or Administration will see the output. Editor and Administration users who are not logged in will see no output.

WARNING: This security setting is overridden by the plugin-wide setting that limits what roles can see data from short codes. In the WP Admin area, go to Contact -> Database Options -> Can See Submission when using shortcodes. If that setting is set to “Author” for example, then no user will less than Author role can see output from any short code even if you have role="Anyone" in a short code. You may find it most useful to set the plugin-wide setting to “Anyone” then use “role” on your short codes. The plugin-wide setting is there to allow an administrator to prevent Contributers, Authors and Editors from writing short codes in posts that might reveal data that they are not permitted to see.

Notes:

  • The Anyone role implies that users do not have to be logged in to see the short code output
  • Case Counts. Be sure to capitalize the first letter of the role names
  • If you set permissionmsg="true" then an error message will show on your page when a user does not have permission. By default, if “role” is being used, no permission error is shown.

Hiding Permission Message with “permissionmsg”

(As of version 2.4.1) In cases where a user does not have adequate permission to view the output of a short code, in place of the short code output, the following message is displayed:

You do not have sufficient permissions to access this data.

If you wish to have no message displayed, set permissionmsg=”false” in your short code.

Limiting How Many Rows to Display with “limit”

Say you just want the first 10 rows, not every form submission. Use “limit”

  • [cfdb-table form="myform" limit="10"] (shows only the first 10 rows)
  • [cfdb-table form="myform" limit="0,10"] (shows only the first 10 rows starting with row #0 which is the first row. This is the same as just using limit=”10″)
  • [cfdb-table form="myform" limit="10,10"] (shows only the first 10 rows starting with row #10. In other words, this shows rows #10-19. The previous example shows rows #0-9. So this is like the next page of 10 rows.
  • [cfdb-table form="myform" limit="20,10"] (shows only the first 10 rows starting with row #20. In other words, this shows rows #20-29. The previous example shows rows #10-19. So this is like the next page of 10 rows.

Choosing Random Rows to Display with “random”

(Available in version 2.4) In cases where you would like to select random rows from those being returned, indicate the number of rows to be returned using “random”.

In these examples, assume there are columns (form fields) named “lastname” and “firstname”
  • [cfdb-table form="myform" random="1"] (return 1 random row)
  • [cfdb-table form="myform" random="2" search="Michael"] (return two random rows that met the search criteria)
The “random” option will show the number of rows you request, or less if less rows are returned from the query. For example, if you have random=”10″ but the short code can only return 5 rows, then 5 are shown.

Sorting by One or More Columns with “orderby”

By default, the results are returned in order of their submission date descending. In other words, the most recent submission entry is first, followed by the next most-recent and so on. But you may want to sort by last name for example. In that case use “orderby”.
In these examples, assume there are columns (form fields) named “lastname” and “firstname”
  • [cfdb-table form="myform" orderby="lastname"] (Sort by lastname column)
  • [cfdb-table form="myform" orderby="lastname,firstname"] (Sort by lastname and for those with the same lastname, sort by firstname)
  • [cfdb-table form="myform" orderby="lastname desc"] (Sort by lastname column in descending (reverse) order. That is, the “Z’s” come first)
  • [cfdb-table form="myform" orderby="lastname desc,firstname desc"] (Reverse-sort by lastname and for those with the same lastname, reverse-sort by firstname)

You can use “asc” for ascending sort or “desc” for descending sort. But “asc” is assumed if not specified.

Choosing which Rows to Display with “search”

The search field acts like the dynamic Search field that appears on the DataTable. It selects rows where any cell contains the search text (case in-sensitive).

  • [cfdb-table form="your-form" search="Washington"] (show only rows where any field contains “Washington” in any case, so “washington” also matches)

Choosing which Rows to Display with “filter”

Filter provides a much more specific and complex way to specify rows to show. Unlike “search”, “filter” specifies searches on specific columns.

  • [cfdb-table form="your-form" filter="field1=value1"] (show only rows where field1=value1)
  • [cfdb-table form="your-form" filter="field1=null"] (SPECIAL CASE: ‘null’ is interpreted as null-value (field does has no value)
  • [cfdb-table form="your-form" filter="field1!=value1"] (show only rows where field1!=value1)
  • [cfdb-table form="your-form" filter="field1=value1&&field2!=value2"](Logical AND the filters using ‘&&’)
  • [cfdb-table form="your-form" filter="field1=value1||field2!=value2"](Logical OR the filters using ‘||’)
  • [cfdb-table form="your-form" filter="field1=value1&&field2!=value2||field3=value3&&field4=value4"](Mixed &&, ||. Standard Boolean operator precedence applies (ANDs are evaluated, then ORs)
  • [cfdb-table form="your-form" filter="field1~~/^a/"] (Regular expression; shows rows where field1 starts with ‘a’)

Filtering Rows: Supported Filter Operators

  • = and == are the same
  • !=<> are the same
  • ><<=>=
  • === and !==
  • ~~ for regular expressions
  • [in], [!in] for “in list” such as:
    • filter"=lastname[in]Simpson,Smith,Jones"

Filtering Rows: Filter by Regular Expressions

  • Use the ~~ operator, and Perl-style delimiters around the pattern, such as /
  • [cfdb-table form="your-form" filter="field1~~/^a/"] (shows rows where field1 starts with ‘a’)
  • [cfdb-table form="your-form" filter="field1~~/.*@gmail.com/i"] (shows rows where field1 is a Gmail address, case-insensitive)
  • FYI: uses preg_match to evaluate the regex

Filtering Rows: How to make “filter” Work Like “search”

Given “search” example:

  • [cfdb-table form="your-form" search="Washington"] (Searches ALL fields)

When using “filter” use regular expressions with case-insensitive option (“i”), listing all fields.

  • [cfdb-table form="your-form" filter="field1~~/.*washington.*/i||field2~~/.*washington.*/i"] (searches field1 and field2. You have to put a regex search for all the fields you want to search when using “filter”, strung together with logical ORs “||” )

Filtering Rows: Filter Limitations

  • Does not support parentheses to control the order of boolean evaluation

Filtering based on Relative Time Using submit_time

For the “submit_time” field only, you can use special time values like:

  • [cfdb-table form="your-form" filter="submit_time>last week"] (shows all submissions since last week)

Read more.

Filtering Rows: Variable Substitution

Advanced options are discussed in  Filter Variable Substitution.

  1. Kaka008
    May 16th, 2011 at 01:17 | #1

    Hi there
    I got question there
    i want to display all the database to the admin
    and only display the database the user submited
    I dont know how to achieve in shortcodes or write in the php

    thanks

  2. Pat Drews
    May 19th, 2011 at 14:51 | #3

    Hi Michael,

    I have a similar question to the above. Is it possible to use the shortcodes to filter database records to display only certain ones based on the wordpress user viewing the results? For example, User Joe is only allowed to see records in which field1=X, while user Jane is only allowed to see records in which field1=Y, etc.?

  3. omrison
    June 4th, 2011 at 09:30 | #5

    i have an error:

    Error: no form is chosen

    the plugin does not know my forms

    • Michael Simpson
      June 4th, 2011 at 12:19 | #6

      The plugin only becomes aware of a form after the first time someone posts to it and the plugin captures it. The plugin is not aware of form definitions.

  4. June 20th, 2011 at 20:40 | #7

    Trying to see if I can get a “running total” from a “donations” so I can post a “Donated this far $$$” Where the $ amount is auto-updated each times someone submits a donation/pledge.

    Thanks for any help.

    Jeremy

  5. Michael Simpson
    June 20th, 2011 at 22:53 | #8

    @Jeremy
    Try something like [cfdb-value function="sum" form="donations" show="amount"]

  6. sam
    July 19th, 2011 at 09:26 | #9

    Michael,

    First off, great work! Keep it up!!! I have a question…..the plugin works perfectly, no issues with that, but is there any way that i could eliminate, somehow, the duplicate records?

    I will make it clear……I wanted to verify if the user exists in the database before inserting new record (based on the email of course). Is there any easy way to do it……By the way i am no good at PHP :(.

    Thanks in advance.

    Cheers!
    Sam.

    • Michael Simpson
      July 19th, 2011 at 11:12 | #10

      No, there isn’t anything like this. I did some thinking about this sort of thing a while back where I wanted to be able to hook into Contact Form 7 validation and provide a way to validate against previously submitted data but I was waiting for them to add in a hook to validate all the fields of the form together (not just individual ones). I’ll put it on my list to look at this again for upcoming releases.

  7. August 9th, 2011 at 10:58 | #11

    Hello
    I want to know if there is a way to embed in the mail an image or a download link with all the captured data
    Thanks
    curdaneta

    • Michael Simpson
      August 9th, 2011 at 11:42 | #12

      This plugin does not do anything with mail. Refer to the Contact Form 7 or Fast Secure Contact Form plugin (which one you are using).

  8. August 27th, 2011 at 12:06 | #13

    hi,
    the “&&” character using with filter doesn’t work. || (or condiction is Ok).
    please can you help me?
    Wp ver 3.2.1
    Plugin Contact Form 7 2.4.6
    Contact Form to DB Extension 2.0.1

    TX

    • Michael Simpson
      August 29th, 2011 at 11:53 | #14

      If you look at your post in the WP editor in HTML mode, do you see “&&” or &amp&amp or a character code? If the latter, change it to the actual ampersand characters and save while in HTML mode in the editor.

  9. September 12th, 2011 at 09:21 | #15

    Hi, great work can’t wait to get my hands dirty on this.. but what are the security aspects using this? Doed this mean an open window for code injection into MySQL..?

    Best regards.

    /S

    • Michael Simpson
      September 12th, 2011 at 09:35 | #16

      No open window to MySQL. The shortcode options are put into prepared statements to avoid SQL injection vulnerabilities. The shortcodes are executed in PHP on the server and the data is generated into the page. It’s not like the page loads and does an Ajax call to get data where such a call could be hacked.

      Anyone who can edit pages can put in a shortcode, so could potentially display any information. There is a setting for who can see the shortcode-generated data. By default it is “anyone” but if raise is above “author” for example, even an author putting a shortcode on a page cannot get the shortcode to generate data.

  10. Felipe
    October 5th, 2011 at 10:41 | #17

    I have a contact form with two drop down menus for a date value ([month][year])
    Could you tell me how I would go about modifying this code so it verifies that the input date is not in the past?
    Is there maybe other type of inputs that I could use?

    Thank you,

    Any help will be greatly appreciated

    Felipe

    • Michael Simpson
      October 5th, 2011 at 11:51 | #18

      Input validation is handled by the form plugin (Contact Form 7 or Fast Secure Contact Form) not but this plugin (which saves data to the DB post-validation).

  11. Germán
    October 18th, 2011 at 16:08 | #19

    Fist, thank you for the great plug in!

    Also, i have a question (sorry, i’m not a php programmer, but i can understand basic stuff)

    How can i display data to all visitors? Not only registered users to admin? I’m using the [cfdb-html] shortcode, but i only can see the data when i’m logged.

  12. Germán
    October 18th, 2011 at 16:11 | #20

    Excuse me, i haven’t see the options page before. Forget my question. Great Plugin.

    • Michael Simpson
      October 18th, 2011 at 16:12 | #21

      Yes, go to the Database Options page, set “Can See Submission when using shortcodes” to “Anyone”

  13. Dana Caulder
    November 3rd, 2011 at 01:44 | #22

    Hi Michael,

    Thanks for all your previous help. I just realized that the URL for uploaded files (both if browsing the database in the plugin pages and when using the short codes) requires admin login. I’d like to use the URL for the uploaded files directly within my WP pages/posts so I don’t have to upload them separately in the media section. Is this possible? Here is an example URL:

    http://www.debug.arundelknights.org/wp-admin/admin-ajax.php?action=cfdb-file&s=1317540700.9519&form=News+and+Events+Submission+Form&field=UploadSupportingPDF

    Thanks,
    Dana

  14. Michael Simpson
    November 3rd, 2011 at 13:03 | #23

    @Dana Caulder
    This is protected by the Database Options setting “Can See Submission when using shortcodes”.
    Set that to “Anyone” and it should work without being logged in.

  15. Dana Caulder
    November 7th, 2011 at 00:18 | #24

    @Michael Simpson
    Thanks, found it!

  16. November 14th, 2011 at 03:31 | #25

    i would like to use the shortcode to display only the uploaded images in form – using the simple [cfdb-table form="myform" show="field1,field2,field3"] (optionally show selected fields) which the fields show up but no image and no image link… If anyone knows a solution please email me – I will pay and donate yet again for the info!!! Awesome plugin…. I’d alos like to be able to control css on page and have images simply show up on page like a gallery…

    • Michael Simpson
      November 14th, 2011 at 08:02 | #26

      Try using cfdb-html with the filelinks option.

  17. December 10th, 2011 at 10:31 | #27

    I need help. I want to showing sum of all the points that have same troop no.

    Please see the link http://babysafecarpet.com/wordpress/please-entry-your-points/

  18. December 27th, 2011 at 09:16 | #29

    I’ve dropped shortcode in a sidebar widget to show upcoming events. Would like to order them in ascending order (nearest in time first). Shortcode I’ve used:

    [cfdb-html form="Submit SEVA Event" orderby="ex_field16 desc" limit="5"]

    The default is supposed to be ascending, but that doesn’t work. I tried specifying ‘asc’ and ‘desc’ but nothing changed. How can I fix this? Thanks!!

  19. January 8th, 2012 at 16:10 | #30

    Hello there!

    I thank you for the time and effort you have devoted into making this!

    I want to organize the results of the form. Is there a way to show the page number?
    My idea is to use the tabel limit and divide them into sections of 20 results (so 0,20, 20,20 etc). But in order to make everything be more clearer I would like to have the row numbers present also, so that once a block is checked I can mark down 0-19 is checked instead of just “first block is checked.”

    So question is short – can I make the row number show?

    Awaiting for your reply.

    Best regards,
    Raimo

    • Michael Simpson
      January 9th, 2012 at 11:07 | #31

      Unfortunately the short codes no not provide a row number you can display. To do this, you would need to create your own shortcode and set up a counter variable.

  20. February 19th, 2012 at 18:54 | #32

    feature request: random orderby for the shortcode display, i have to use jquery to randomize the list right now

  21. February 23rd, 2012 at 08:24 | #33

    How can i put a something like a search bar whereby a field in the form will be input and all other fields will just appear

  22. February 23rd, 2012 at 12:21 | #34

    Please i need a shortcode that will put a search bar on my page whereby users will be able to search for a specific name and every thing will just appear.

  23. Ace
    February 29th, 2012 at 21:46 | #35

    @Bhadem
    Try taking a look at data tables here: http://datatables.net/release-datatables/examples/basic_init/themes.html

    It’s a JQuery plugin which will take what has been spit out and make a grid of data / add paging and an ajax search bar. no mess with default filtering.

  24. March 7th, 2012 at 12:00 | #36

    I’ve said it before, but amazing plugin Michael. This was definitely an essential tool missing in wp until you came along, thank you very much.

    I’m having trouble with the shortcodes. Is there a simple way to produce a shortcode which only shows data from the previous day?
    Thanks.

    • Michael Simpson
      March 7th, 2012 at 12:03 | #37

      example: [cfdb-table form=”Contact form” filter=”submit_time>yesterday”]

  25. Chris
    March 13th, 2012 at 08:13 | #38

    Hi, thanks for your plugin.
    Is it possible to set the table field titles within the shortcode?
    I know that i can set them inside the Contact form settings, but unfortunately i found your plugin today and i have already many forms.
    Thanks anyway!!!
    Great job

    • Michael Simpson
      March 13th, 2012 at 09:43 | #39

      Not right now. I plan to put in something to allow you to set a column’s display name (like should “first_name” as “First Name”) but I haven’t done that yet. Your only recourse right now is to rename the fields in the database. You can do this with my editor extension by just renaming a column. But you have to pay for that. Otherwise you can execute SQL such as update wp_cf7dbplugin_submits set field_name = 'your-new-field-name' where field_name = 'your-old-field-name' and form_name = 'your-form-name'

  26. Sky
    March 26th, 2012 at 01:17 | #40

    Hi , i need to check phone number and email duplicacy check in contact form 7 db extension , but i have not found it any where , i want to know that it is possible or not , or have to code in plugin. , any help will be appreciated. Thanks in advanced.

    • Michael Simpson
      March 26th, 2012 at 10:31 | #41

      Currently no validations are done by this plugin before entering it into the db. Also, no specific support in export or short codes for querying for duplicates.

  27. Filip
    March 28th, 2012 at 04:40 | #42

    Hi There,

    I am looking to integrate this form with a directory plugin. I would like to create a job listing page with the “apply now” link for each listing opening the form on click. Is there a way to make the form automatically grab the id of the job so that the receiving end knows which job is being applied for?

    I would be grateful for your feedback,

    Thanks,

    Filip

    • Michael Simpson
      March 28th, 2012 at 10:58 | #43

      Not clear: are the jobs in the DB managed by this plugin and you are going to use a short code to pull out job listings and create an apply now form? Or are the job listings coming from somewhere else? And how are you creating that apply form, via a plugin like CF7 or writing your own HTML?

  28. Peter
    April 11th, 2012 at 12:52 | #44

    Hi,

    Lovely plugin – I have a problem with inplementering of a regular expression. When I use”]”. My expression working fint inside the short code editor but goes wrong when I put the short code into a page.
    here is my short code
    [cfdb-count form=”Tilmelding” filter=”fdato~~/-1995?[5-9]/||fdato~~/-2000?[0-3]/”]
    I attempt to insert the short code in the HTML view without result

    Any help will be appreciated for my further work.
    Thanks in advanced.

    • Michael Simpson
      April 14th, 2012 at 10:30 | #45

      Sounds like WordPress is not properly parsing the tag. I haven’t tried it, but if you put in “]]” instead of “]” it may escape the character. Let me know if that works.

  29. May 5th, 2012 at 12:53 | #46

    Great plugin- but I have one problem: I’m using this shortcode [cfdb-value form="Endorse" show="/.*name/" orderby="lastname desc"] to show people’s names but there is a coma between the first and last name. how do I eliminate it?

    • Michael Simpson
      May 5th, 2012 at 15:32 | #47

      try: [cfdb-value form="Endorse" show="/.*name/" orderby="lastname desc" delimiter=" "]

  30. Muneer Ahmad
    July 7th, 2012 at 01:08 | #48

    Hi i want know how i can set username and password field in this plugin and i want if a user registred then first i approve the user after that he registred so plz tell me how i do this

    • Michael Simpson
      July 7th, 2012 at 12:49 | #49

      This plugin does not do anything with WordPress user registration.

  31. Philippe
    July 17th, 2012 at 10:42 | #50

    Is there a way to generate a barcode after a form has been submitted?
    The barcode should be included automatically in the database and should be mailed to who filled out the form.

    • Michael Simpson
      July 17th, 2012 at 17:56 | #51

      There is no direct support for bar code generation. I don’t know how to generate a bar code. But let me assume there is some code or plugin that you could use to do this. You might then use the filter hook that this short code provides. Instead of injecting a new date field like the example on that page describes, you would somehow generate a bar code and add it to the submission data which would then be saved to the DB.

      However that does not address mailing it. You might need to call wp_mail to send mail directly from the filter function that you write.

  32. stcc
    August 7th, 2012 at 12:57 | #52

    Hi;

    First of all, Thank you very much for this great plugin!

    I have created a form with contact form 7, then I am using your plugin to export data /display data, however, I noticed that there is no way to prevent duplicate entries. For example following is the result from my table:

    code status
    ————–
    1234 Returned
    4546 Returned
    1234 Returned
    1234 Returned
    1234 Returned

    I hope the data can be displayed as:
    code status
    ————–
    1234 Returned
    4546 Returned

    How should I do? I will greatly appreciate if you can give me some hints. Thank you!

    stcc

  33. stcc
    August 8th, 2012 at 11:48 | #54

    Hi Michael:

    Thank you very much for your reply. I searched on wordpress website, and found the question/answer here:

    http://wordpress.org/support/topic/plugin-fast-secure-contact-form-check-email-field-in-the-db-for-error-using-cf-to-db-ext?replies=7#post-3054285

    I am wondering where I should put the code Daniele wrote: do I put them in the function.php? how should I call/use it in the post/page? or I should put them in the “short-code php” sections (found in the admin page)?

    I will appreciate if you can give me some help. Thank you!

  34. sommy
    August 11th, 2012 at 03:51 | #55

    is it possible to edit the entries from the frontend (not from database directly) of the page so that my users can directly update few fields…

    • Michael Simpson
      August 11th, 2012 at 09:50 | #56

      No, you can only edit entries from the administration page.

  35. August 26th, 2012 at 07:57 | #57

    Can I create auto-approved posts with the database filled in contact form 7? Eg. the visitor fill the form without registration/login and the data of the form become the title and description of the post and that post become live and approved- All automatically?
    Reply – Thank You

    • Michael Simpson
      August 26th, 2012 at 09:45 | #58

      You can do this with a similar plugin I wrote. See Form to Post

  36. August 26th, 2012 at 10:11 | #59

    Hello, quick question. I love your plugin it has made my life so much easier, however I am wondering how to go about using information from the DB to populate my CF7 form. I have read various posts on this already and all require you to change code in the backend. Is their a way to do it without altering any code?

    • Michael Simpson
      August 26th, 2012 at 10:32 | #60

      There is no easy way to do this that I know. I have tried seeing if I can wrap a CF7 form short code inside a cfdb-html short code, putting in ${variable} values as defaults in the CF7 definition but that doesn’t work.

  37. AJ
    August 29th, 2012 at 05:40 | #61

    Is there a way to input conditional somewhere within this shortcode to only pull the database records for a particular user. So for instance, when someone goes to their My Systems page, after they’ve submitted a new system, and this is captured on this form, how do I ensure that it is filtered universally at the user id level?

  38. AJ
    August 29th, 2012 at 05:42 | #62

    So, in other words, I only want users to see their own form submission data. Regardless of what permission level they are at. What would be the best way to skin this cat?

  39. AJ
    August 29th, 2012 at 06:01 | #63

    [cfdb-table form="My Systems" role="Anyone" permissionmsg="false" filter="Submitted User ID="(I WOULD LIKE TO BE ADD PHP CODE HERE TO DYNAMICALLY PLACE THE CURRENT WORDPRESS USER ID"]

  40. September 26th, 2012 at 11:16 | #65

    Hey Michael,

    Love the plugin! I have 2 questions:

    1. Is it possible to have a submission show up in a different color if a certain option in CF7 is checked? For instance, I want to add a checkbox on my form that says “Are you paying by check?” and have a Yes/No option. If they click “Yes” I would still like them to show up in the submissions but I would like them to be in a different color than the other submissions. Possible?

    2. I am using your shortcodes in WP Table Reloaded and I notice that they don’t automatically update with latest/newest submissions. To get new submissions to show up, I have to remove the shortcode and put it in again. What could be the reason for this?

    Thanks! 🙂

    • Michael Simpson
      September 26th, 2012 at 20:08 | #66

      1. I think you would need to create a custom short code to accomplish that.

      2. Unfortunately I don’t really know anything about WP Table Reloaded so I can’t answer intelligently.

  41. October 7th, 2012 at 10:34 | #67

    Hello

    Great plug in thanks so much.

    I have few issues i wonder if you could help me with.

    1. I want to give the values in a drop menu different hidden revenue values. i.e if someone select gatwick the hidden value is £70 and if they select heathrow the hidden value is £80. Can i achieve this?

    (see this example: http://cheap-airport-taxis.com/contact-form-address/ )

    2. Is there a way to Auto-generate a new Booking ID every time a form is completed?

    3. Is there a time picker extension for this plug in as there is a date picker calendar extension?

    • Michael Simpson
      October 7th, 2012 at 18:45 | #68

      1. This is something you would need to accomplish in the form definition and not this plugin. A form input tag can have a display value and actual value. The latter is saved. For example if you have a drop downlist, you have a SELECT tag nested OPTION tags likewhere the user sees Gatwick and 70 gets saved to the DB. You either write this HTML directly or you have to figure out how to do it using whatever form plugin you use.

      2. Note that each entry has a unique “submit_time” field. In the admin page this gets displayed as “Submitted” in the admin page and is formatted as a time. But in the DB it is saved as a value like 1342034011.0136 which is unique per form submission. You can add show=”submit_time” to a short code to display that value. Consider using that as your ID. If you actually want to generate your own value, then you would need to following this example to add another field (requires some coding).

      3. That is a question for the plugin for generating/displaying the form itself, not this plugin.

  42. October 11th, 2012 at 14:44 | #69

    Michael, first….great plugin! I keep finding new and wondrous things in it each day, but I have no idea how to implement them… very frustrating but endlessly entertaining!
    My site feeds data to the database from several different forms. What I am trying to do is extract some of the data by querying whether a certain field has any data in it and if so extract the whole row.
    I see above: [cfdb-table form="your-form" filter="field1!=value1"] (show only rows where field1!=value1) – Is this where I should be concentrating? If so what “value1” equals data in the field and conversely what “value1” equals no data in the field? Can it be black or white like that or does it need a specific word or number as “value1” to search for?
    If need be I could add a different default textfield to each form which would have a “value1” for it to search for, would that work?
    Thank you very much in advance for your reply.

    • Michael Simpson
      October 11th, 2012 at 17:20 | #70

      I replied on the WP forum to your post there.

  43. October 14th, 2012 at 14:48 | #71

    @James

    hello mike im new to this plug in so thanks for getting back.

    here’s my comments back

    1. This is something you would need to accomplish in the form definition and not this plugin. A form input tag can have a display value and actual value. The latter is saved. For example if you have a drop downlist, you have a SELECT tag nested OPTION tags like
    where the user sees Gatwick and 70 gets saved to the DB. You either write this HTML directly or you have to figure out how to do it using whatever form plugin you use.

    — I am using the contact form 7 plug in to generate the form so do you know if I can achieve this just using the standard options in this plugin?

    2. Note that each entry has a unique “submit_time” field. In the admin page this gets displayed as “Submitted” in the admin page and is formatted as a time. But in the DB it is saved as a value like 1342034011.0136 which is unique per form submission. You can add show=”submit_time” to a short code to display that value. Consider using that as your ID. If you actually want to generate your own value, then you would need to following this example to add another field (requires some coding).

    — great this sounds good i’ll try it. do you know why all the examples refer to “my form” (like the below)
    [cfdb-value form="myform" show="col1,col2"]

    where as my short code that is generated has an id and title? this is confusing me. would my code look like the below based on your suggestion?
    [contact-form-7 id="2872" title="database-test" show="submit_time" ]

    3. That is a question for the plugin for generating/displaying the form itself, not this plugin.

    Yeah can’t believe there there’s no time picker extension for contact form 7

  44. Peter
    November 20th, 2012 at 17:06 | #72

    Hi,
    I got the shortcodes to display results in posts and even in Contact Form 7 forms themselves by following http://wordpress.stackexchange.com/questions/45266/how-to-use-other-shortcodes-inside-contact-form-7-forms.
    But they don’t work in the mails that are being send after submission.
    Any solutions to that?
    Thnx a lot…

  45. December 13th, 2012 at 10:33 | #73

    sam :
    Michael,
    First off, great work! Keep it up!!! I have a question…..the plugin works perfectly, no issues with that, but is there any way that i could eliminate, somehow, the duplicate records?
    I will make it clear……I wanted to verify if the user exists in the database before inserting new record (based on the email of course). Is there any easy way to do it……By the way i am no good at PHP .
    Thanks in advance.
    Cheers!
    Sam.

    Michael Simpson :
    No, there isn’t anything like this. I did some thinking about this sort of thing a while back where I wanted to be able to hook into Contact Form 7 validation and provide a way to validate against previously submitted data but I was waiting for them to add in a hook to validate all the fields of the form together (not just individual ones). I’ll put it on my list to look at this again for upcoming releases.

    Any follow on that?

    Really need to do this for a contest.

  46. December 20th, 2012 at 16:47 | #75

    Any way to get it to automatically send (email) a CSV export file daily with the results from the past 24 hours?

    • Michael Simpson
      December 20th, 2012 at 17:11 | #76

      No. On the short code builder page, you could create an export link with a filter like “submit_time>yesterday” or “submit_time>-24hours” (reference) so that it always exports a CSV file with the latest results. But getting that to email you is not supported by the plugin.

  47. February 13th, 2013 at 19:31 | #77

    sorry for the stupidness, but i don’t understand the directions for changing the table’s header row names. My Fast Secure Contact Form calls the fields something like “ex_field1” and I need a more descriptive field name, like “Job Number”. I tried using the the short code, which displays the table beautifully, except I don’t understand how to effectively follow the instructions for changing the ID names (at least that’s what I think should work). Any help would be appreciated. You ROCK. This plugin is super. Thanks for all your wonderful work.

  48. Michael Simpson
    February 13th, 2013 at 20:44 | #78

    @Sallie
    cfdb-table and cfdb-datatable don’t have options to rename the column names at present.

  49. April 11th, 2013 at 08:24 | #79

    Hi Michael,
    I have very simple question. I don’t want to show the whole data-table to the user except the search field. If any one put any query (e.g. telephone number, name etc.) it will shows only that row of the table.

  50. Paul
    April 26th, 2013 at 14:01 | #80

    Hi Michael,

    Can I set up an automated export, either daily or hourly for example?

    Alternativly, how can I connect to our database remotly (eg, Microsoft SQL Server SSIS package running daily). A valid connection string is what I’m looking for.

    What we are trying to do is import the contact information into our existing CRM solution.

    • Michael Simpson
      April 26th, 2013 at 22:48 | #81

      In the admin area, the Short Code builder page allows you to create export links. Another application could use the URL you create to access the data (required it to login). Regarding do that in an automated way, you will have to set up something to access the URL on a schedule. On Linux you can use “cron” for example.

  51. Jon
    May 8th, 2013 at 15:09 | #82

    Hi Michael,

    Is there a way to filter based on whether a value exists in a column? Essentially it would be the opposite of [cfdb-table form="your-form" filter="field1=null"] but unfortunately I can’t just use [cfdb-table form="your-form" filter="field1=value1"] because the value will be different from submission to submission. However I would like to see if I can show all rows where a value exists (any value) within a particular column.

    Thanks for your support!

    • Michael Simpson
      May 8th, 2013 at 15:46 | #83

      Use “!=”, i.e. filter=”field1!=null”

  52. Jon
    May 8th, 2013 at 18:12 | #84

    Perfect! Thank you!@Michael Simpson

  53. praveen
    May 14th, 2013 at 14:03 | #85

    Michael -Thank You Very Much For Your Great Plugin..xcllent work
    I hav One Question…I don Know Whether is It Possible Or not

    i installed ur plugin & data base plugin too
    as your plugin hav dababase acces..is it possible to post users sent data through Fs Contact Form On My WordPress Site Like A admin Posts?

    if it does ..will it automatically publishes users submited data as post??

    In Settings I could See Only Export Option.. I didn see Publish option?
    Im a Neebie For WordPress…

    • Michael Simpson
      May 15th, 2013 at 07:20 | #86

      This plugin saves form submissions in the database but does not make them into posts. Use the form-to-post plugin to do that. It will publish posts by default, or you can set the “post_status” to change that.

  54. David
    May 30th, 2013 at 16:31 | #87

    How do you hide columns that are null. Filter does not work on columns. I want to hide any column starting with the word pull that has no value. I’ve tried hide=”/pull.*/=null” but it doesn’t work.

    • Michael Simpson
      May 30th, 2013 at 17:26 | #88

      “filter” works on rows, “hide” works on columns. Each is independent. You can’t combine “filter” and “hide” to hide columns that have empty row values.

  55. June 13th, 2013 at 04:34 | #89

    have to show data with CF-DB, i want to show data after approved by admin on my site.

    Please any soon…

    • Michael Simpson
      June 13th, 2013 at 13:22 | #90

      I think you are asking how to show only the data that has been approved by an administrator. If you purchase the CFDB Editor Plugin, you can create a new column associated with your form data. You might name the column “Approved”. Then set the value of “Approved” to “yes” on the rows you wish to have displayed. Finally, in a short code filter on “Approved”. For example:
      [cfdb-table form="form-name" filter="Approved=yes"]

  56. June 15th, 2013 at 16:15 | #91

    Hey Michael,

    Quick question, I have a page to show the database of people that have submitted form. But it doesn’t populate unless I’m logged in as admin. Is there a way to make it populate without having to be logged in as long as they can access the page? I’m not sure if this is a role or security short code I’m doing wrong.

    • Michael Simpson
      June 17th, 2013 at 10:14 | #92

      In Contact Form DB -> Options, you probably need to change “Can See Submission data” to something less than “Administrator”

  57. Mike
    July 31st, 2013 at 13:13 | #93

    I am using the order by clause on a numeric field by the information is not ordering as I expect, for instance 100 is appearing before 70 – so i get results such as:

    109
    117
    401
    51
    58
    99

    It appears to be ordering using alpha convention. Is there anyway to treat the column as numeric

  58. johnja1
    April 15th, 2014 at 20:13 | #94

    Hey Michael,
    I have a similar problem as Mike, Is there a way to orderby ASC Or DESC if the field is numeric. I then change my field to text and still the number do not orderby correctly. Is this a bug. This is a fantastic plugin and very use to desplay data on a page. Please advice

    Many thanks
    Jacob

    • Michael Simpson
      April 17th, 2014 at 10:31 | #95

      Unfortunately, the plugin sorts everything treating it as text. On my to-do list to make it sort numbers and dates.

  59. johnja1
    April 17th, 2014 at 11:18 | #96

    Hi Michael,

    Thank you for your response, I know you are busy man. I change the field to text but it still did not sort as DESC order. Also Is there a way to trim or center the fields on the columns? I tried using trim() for leading spaces but it did not work. Color for the labels is something I wanted to do but no idea how to do it.

    Many Thanks
    Jacob

  60. Michael Simpson
    April 26th, 2014 at 12:03 | #97

    should work: orderby=”field-name desc”

    PS. If you want to write PHP to sort the data how you like then you can create your own short code: http://cfdbplugin.com/?page_id=444

    To center the fields in the columns, apply CSS to the table. You can do this with the “style” attribute on the short code: http://cfdbplugin.com/?page_id=93#style

Comments are closed.  Go To Support Forum