[cfdb-export-link]

This documentation applies to version 2.6 and later

Summary of Shortcode Options

Option Example
Description
form [cfdb-export-link form="myform"] Required. Designates the form to display. All rows and columns are displayed by default
role [cfdb-datatable form="myform" role="Author"] Make short code only display output for user’s with minimum-required role. Choices are

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

WARNING: this setting is overridden by plugin setting in WP Admin page Contact -> Database Options -> Can See Submission when using shortcodes
(since 2.4.1)

show [cfdb-export-link form="myform" show="col1,col2"] Limits columns to be shown to be those designated (comma-delimited list)
hide [cfdb-export-link form="myform" hide="col1,col2"] Does not show listed columns (comma-delimited list)
limit [cfdb-export-link form="myform" limit="10"] One number: limit=”10″ means show first 10 rows. Is the same as limit=”0,10″
Two Numbers: limit=”100,10″ means show 10 rows starting at row #100)
random [cfdb-table form="myform" random="2"] Display 2 random rows from those that the short code finds. (Since 2.4)
orderby [cfdb-export-link form="myform" orderby="last-name,first-name"] Sort rows by designated columns. Use “column-name desc” to sort in descending (reverse) order
search [cfdb-export-link form="myform" search="Simpson"] Select rows to display that have any cell with the search text in it (case insensitive). Intended to mimic behavior of the “Search” field in the DataTable
filter [cfdb-export-link form="myform" filter="col1=Simpson"] Select which rows to display based on filter expression. More powerful than “search”, it can filter on multiple columns with boolean and regular expressions. If both “search” and “filter” are specified, “search” is ignored.
Options specific to this shortcode
enc [cfdb-export-link form="myform" enc="CSVUTF8BOM"] Set the encoding/format of the export file. Options are:

  • CSVUTF8BOM (Excel CSV: Comma-Separated Value, UTF-8 encoding with Byte Order Mark)
  • TSVUTF16LEBOM (Excel TSV: Tab-Separated Value, UTF-16 Little-Endian encoding with Byte Order Mark)
  • CSVUTF8 (Plain CSV: Comma-Separated Value, UTF-8 encoding)
  • IQY (Excel IQuery file: UTF-8)

If not specified, CSVUTF8 is assumed.

urlonly [cfdb-export-link form="myform" urlonly="true"] By default an HTML anchor tag is output to make a clickable link. setting urlonly=”true” makes the shortcode only output the URL text
linktext [cfdb-export-link form="myform" linktext="Download"] By default an HTML anchor tag that is output is labeled “Export”. Use this option to change the text of that link.

 

Use [cfdb-export-link form="your-form"] with optional show, hide and filter just like[cfdb-table].

The purpose of this tag is to output an HTML link which, when clicked, will download a file in a CSV or related format. This is the same as the export options available in the Database page in the WP admin area.

WARNING: When clicking your link, you will get a “Permission Denied” error unless the user has permission to see data according to the “Can See Submission data” option (see Database Options page). When a user has this access, he can then hand-craft URLs to download any and all data from any form in your database. Setting this option to “Anyone” opens up a security hole where any savvy user can construct URLs to see all the submitted form data you have. So use this option with care.

Some people wish to have only those results downloaded that are associated with a specific user. That can be accomplished. See the page on filter variable substitution using $user_login. But note that although the short code link only shows that user’s data, a savvy user can change the link to see other data. The security options in the plugin’s Options panel allow one to set what level of user can see data (Administration, Editor, etc.) but this is a all-or-nothing proposition. Users that can see data can see all the data. And hacking the URL output by this short code is an easy way to see data that was not intended by a shortcode.

 

Use enc to indicate output file format. The choices are described above.

 

Use urlonly to only output the URL to the export instead of an HTML A tag.

 

Use linktext to change the label for the HTML A tag. By default the label is “Export”, for example:
<a href=”http://….”>Export</a>

 

  1. October 21st, 2012 at 20:14 | #1

    Hi
    I am trying to provide a download line (csv file) from a post.
    The issue is that the form contains Hebrew characters.
    The above enc=”CSVUTF8BOM” which is the required setting does not work for me here.

    However, from the admin page using UTF8+BOM or TSV, both works fine.
    Display the link from the admin page works fine – but I cannot filter out columns.

    How can I use the above command? (or why the is a difference?)
    Thanks

    • Michael Simpson
      October 23rd, 2012 at 10:59 | #2

      Can’t you just use enc=”TSVUTF16LEBOM” in the short code? I don’t understand why you say CSVUTF8BOM is required.
      Are you saying that “filter” does not work with the cfdb-export-link shortcode?

  2. saj
    June 14th, 2013 at 07:01 | #3

    i have created a export link shortcode
    [cfdb-export-link form="Enquiry_copy" show="submit_time,name,contactno,traveldate,Submitted" filter="submit_time>$_GET(start)&&submit_time<$_GET(end)"] … but it shows empty results.. it is not getting the dates… please help

  1. No trackbacks yet.
You must be logged in to post a comment.