Atttachments

How to allow my front-end users to upload attachments in front-end uploader?

By default, WordPress Media Library (used for attachments) allows file uploads only for users who have the upload_files capability. So, everyone who doesn’t have this capability (e.g. a subscriber) will receive an error on trying to upload a file.

To add this capability to subscribers you can e.g. use the User Role Editor plugin. Just enable the upload_files capability for the users which need it and it will work.

Other option is to add this capability dynamically via a hook. To do this you can add e.g. this code to your theme’s functions.php:

            function give_permissions( $allcaps, $cap, $args ) {
                $allcaps['upload_files'] = true;
                return $allcaps;
            }
            add_filter( 'user_has_cap', 'give_permissions', 0, 3 );     

Basically, it enables the upload_files capability to everyone – but you can extend this logic to allow it only for certain users at certain moments.

Permalink 0 0

How to allow logged out users to upload attachments?

By default WordPress does not allow this. Reason is: logged out user has no ID (id is 0), and no permissions/capabilities enabled for him.

A solution would be to create an actual user that will be used as a single user for all logged-out users, and copy his ID (e.g. id = 100).

Then you can add a simple hook to identify logged out users as User with ID 100. To do this you can use a hook like this:

    function set_loggedout_id( $user_id ){
       if( empty( $user_id ) ){
          $user_id = 100;
       }
       return $user_id;
    }
            
    add_filter( 'determine_current_user', 'set_loggedout_id', 999, 1 );

Basically, it “tells” WordPress to replace the empty ID of a logged out user with a value of 100.
Then you can allow uploading for this user.

Permalink 1 1

I don’t see the upload media library!

Please check if you maybe have some inline JS minifier tool enabled, e.g. W3TotalCache – inline minification of JS breaks the front-end uploader template logic.

Permalink 1 0

Filtering

How to use URL parameters for filtering?

Tables can be filtered with query string that consists of “wdtColumnFilter[KEY]” value pairs where KEY is zero based numerical index of the column you would like to filter or initial column header. E.g.

?wdt_column_filter[1]=Asia&wdt_column_filter[country]=Thailand

Values passed from URL will be used as default filter values therefore “Advanced filtering” option needs to be enabled on table edit page.

Permalink 1 0

How to filter table by invisible columns?

If you like to have invisible columns in filters, that can be achieved by enabling “Filter in form” option in table edit page.
“Filter in form” option will create filters as a separate section from the table and additionally show filters for all hidden columns.
Currently there is no option in admin section for hiding unwanted filters from form, but the easiest way that can be done is using CSS.

Permalink 0 2

Individual column filtering works, but global search doesn’t return anything. Why?

This usually happens for MySQL-based tables with server-side processing turned on.

Please check if you have a complicated query with JOINs, calculated columns (e.g. ” SELECT mycolumn*2 AS mycolumn2″), or some custom column aliases (e.g. “SELECT mycolumn AS ‘some/weird/name’). If this is the case, please either create a MySQL view (in PHPMyAdmin or similar MySQL DB manager) and build a wpDataTable based on this view.

Permalink 0 0

Front-end

I added a table but see no sorting, filtering or pagination

  • Please check first if PHP version is at least 5.4 or newer. It is required for proper running of wpDataTables.
  • Second thing to check is that there are no JS errors in the javascript console. Please check e.g. in Chrome JS console. Usually when we investigate such things we find out that some other plugin or theme are broken, and wpDataTables JS cannot execute.
  • Please try switching the theme to a different one and see if it helps.
  • Feel free to open a support ticket, providing us with the URL of the page so we could tell why does it happen.

Permalink 1 5

How to hide one of the Table Tools buttons?

The easiest way to do this is via CSS.
This is the block of code for hidding all the table tools individual buttons:
/*Hide copy button*/
.wpDataTables button.DTTT_button_copy { display: none !important; }

/*Hide PDF button*/
.wpDataTables button.DTTT_button_pdf { display: none !important; }

/*Hide CSV button*/
.wpDataTables button.DTTT_button_csv { display: none !important; }

/*Hide print button*/
.wpDataTables button.DTTT_button_print { display: none !important; }

/*Hide excel button*/
.wpDataTables button.DTTT_button_xls { display: none !important; }

/*Hide edit button*/
.wpDataTables button.DTTT_button_edit { display: none !important; }

/*Hide new button*/
.wpDataTables button.DTTT_button_new { display: none !important; }

/*Hide delete button*/
.wpDataTables button.DTTT_button_delete { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
.wpDataTables button.DTTT_button_csv { display: none !important; }
</style>

The other best way to achieve this is using plugin’s “wpdatatables_filter_table_description” filter hook.
You can create function similar to this one and add it to previously mentioned filter hook. E.g.

function hide_wdt_table_tools_buttons( $descObj, $table_id ) {
    if(isset( $descObj->dataTableParams->oTableTools )) {
       foreach( $descObj->dataTableParams->oTableTools['aButtons'] as $index => $button ) {
          if(is_array( $button )) {
             $button_type = $button['sExtends'];
          } else {
             $button_type = $button;
          }

         if( $button_type == 'xls' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'print' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'csv' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'pdf' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'copy' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }
       }

       $descObj->dataTableParams->oTableTools['aButtons'] = array_values( $descObj->dataTableParams->oTableTools['aButtons'] );

   }

   return $descObj;

}

Permalink 0 1

Front-end edit dialog is not showing any/all columns fields in the table

Front-end edit dialog will allow editing values for only those columns that have set option “Editor input type” in edit table page.
If you don’t see any columns fields or missing some, the reason is most likely that the option “Editor input type” is set to “None” for those missing columns.

Permalink 2 2

How to filter table by invisible columns?

If you like to have invisible columns in filters, that can be achieved by enabling “Filter in form” option in table edit page.
“Filter in form” option will create filters as a separate section from the table and additionally show filters for all hidden columns.
Currently there is no option in admin section for hiding unwanted filters from form, but the easiest way that can be done is using CSS.

Permalink 0 2

How to disable opening links in a popup?

File that is responsible for rendering link columns is /source/class.link.wpdatacolumn.php
By opening that file you can see code for creating html anchor element with attribute “target=’_blank'”.
By changing ‘_blank’ value to ‘_self’ will cause link to open in same page instead of new window.

Permalink 0 0

How to show only the filter and do not show the table until user type something in the search box

First you’d need to hide the table, the info and pagination block with CSS (display: none), leaving the filter visible. Add this code to Custom CSS filed on Settings page:

#table_1, #table_1_info, #table_1_paginate { display: none }

Then you’d need to insert a jQuery snippet on the page similar to the following (please note that it’s not universal, some changes might be needed to fit your page):

jQuery('#table_1_filter input').keyup(function(e){ if( $(this).val().length > 3 ){ $('#table_1,#table_1_info,#table_1_paginate').show() } else { $('#table_1,#table_1_info,#table_1_paginate').hide(); } });

In this case table will appear only when more than 3 chars are typed in the search box. You can adjust it by inserting a proper table ID, or changing ‘3’ to something else.

Permalink 0 0

Front-end editor

Front-end edit dialog is not showing any/all columns fields in the table

Front-end edit dialog will allow editing values for only those columns that have set option “Editor input type” in edit table page.
If you don’t see any columns fields or missing some, the reason is most likely that the option “Editor input type” is set to “None” for those missing columns.

Permalink 2 2

MySQL

Can’t connect to remote MySql database

If you are using separate MySql connection option to connect to mysql database, you can test if connection can actually be established with “Test MySQL settings” button.
If connection can’t be established, first please make sure that all entered values needed for connection are correct.
Also make sure that MySql server is allowing remote connections and that MySql user that you are trying to connect with is allowed to connect from your sites host(IP address).

Permalink 0 0

How to create MySql query that uses tables from multiple databases?

This can be achieved with adding database name in front of a table name in MySql query.
For example:
SELECT * FROM database_name1.table1_name tb1 INNER JOIN database_name2.table2_name tb2 ON tb1.field_name=tb2.field_name

Just please make sure that MySql user that your site is connecting with has the right privileges for every database in MySql query.

Permalink 0 0

Individual column filtering works, but global search doesn’t return anything. Why?

This usually happens for MySQL-based tables with server-side processing turned on.

Please check if you have a complicated query with JOINs, calculated columns (e.g. ” SELECT mycolumn*2 AS mycolumn2″), or some custom column aliases (e.g. “SELECT mycolumn AS ‘some/weird/name’). If this is the case, please either create a MySQL view (in PHPMyAdmin or similar MySQL DB manager) and build a wpDataTable based on this view.

Permalink 0 0

Pagination

How to hide “Show X entries” block from pagination?

The easiest way to do this is to put this CSS block somewhere in your theme’s CSS file, or in inline CSS:
div.dataTables_length { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
div.dataTables_length { display: none !important; }
</style>

Permalink 1 0

How to hide “Showing X of X entries” in pagination?

The easiest way to do this is to put this CSS block somewhere in your theme’s CSS file, or in inline CSS:
div.dataTables_info { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
div.dataTables_info { display: none !important; }
</style>

Permalink 1 0

Table look and feel

How to make my table responsive on desktop?

Firstly “responsive” feature needs to be enabled for the table.
This can be done in wpDataTables table edit page by ticking “Responsive” checkbox in “Data source and main settings” section and saving changes.

Second step involves going to the wpDataTables Settings page and setting “Tablet width” option to large value (e.g. 2000) and saving options.

Permalink 0 1

How can I hide columns in the table?

In wpDataTables table edit page in section ” Optional column setup” for every table column there is “Visible” check-box.
This check-box needs to be unchecked for columns that you wish to be invisible on the front-end and changes saved.

It is recommanded that if you don’t need certain columns to remove it from data source or select query for mysql tables if possible.
It will speed up loading of the page and result in more clear look of column setup section.

Permalink 0 0

Adding text before/after column values without affecting sorting

In wpDataTables table edit page in section ” Optional column setup”, for every table column there are text fields “Display text before” and “Display text after”.
Values from those text fields will be used for adding text before or/and after every cell content in a column.
This feature uses css for displaying entered text, therefore sorting of the columns will not be affected.

Permalink 2 0

How to change display date format of a date column?

Display date format of a date column can be changed in wpDataTables Settings page from “Date format” drop-down menu.

Permalink 0 0

How to change thousand and decimal separators for number columns?

This can be changed from “Number format” drop-down menu in the wpDataTables Settings page.

Permalink 1 1

How to display table column filters in header?

In order to show column filters in header “Render advanced filter” option needs to be changed to “In the header” on wpDataTables Settings page.

Permalink 1 0

How to hide global search block?

The easiest way to do this is to put this CSS block somewhere in your theme’s CSS file, or in inline CSS:
div.dataTables_filter { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
div.dataTables_filter { display: none !important; }
</style>

Permalink 1 1

How to hide “Show X entries” block from pagination?

The easiest way to do this is to put this CSS block somewhere in your theme’s CSS file, or in inline CSS:
div.dataTables_length { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
div.dataTables_length { display: none !important; }
</style>

Permalink 1 0

How to hide “Showing X of X entries” in pagination?

The easiest way to do this is to put this CSS block somewhere in your theme’s CSS file, or in inline CSS:
div.dataTables_info { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
div.dataTables_info { display: none !important; }
</style>

Permalink 1 0

How to hide one of the Table Tools buttons?

The easiest way to do this is via CSS.
This is the block of code for hidding all the table tools individual buttons:
/*Hide copy button*/
.wpDataTables button.DTTT_button_copy { display: none !important; }

/*Hide PDF button*/
.wpDataTables button.DTTT_button_pdf { display: none !important; }

/*Hide CSV button*/
.wpDataTables button.DTTT_button_csv { display: none !important; }

/*Hide print button*/
.wpDataTables button.DTTT_button_print { display: none !important; }

/*Hide excel button*/
.wpDataTables button.DTTT_button_xls { display: none !important; }

/*Hide edit button*/
.wpDataTables button.DTTT_button_edit { display: none !important; }

/*Hide new button*/
.wpDataTables button.DTTT_button_new { display: none !important; }

/*Hide delete button*/
.wpDataTables button.DTTT_button_delete { display: none !important; }

If you wish to apply this code to all of your wpDataTables tables, you can put it in “Custom wpDataTables CSS” text area on wpDataTables Settings page,
or if you wish to apply it only on specific pages, you can put it in between style tags in for example html editor bellow tables short codes. E.g.

<style>
.wpDataTables button.DTTT_button_csv { display: none !important; }
</style>

The other best way to achieve this is using plugin’s “wpdatatables_filter_table_description” filter hook.
You can create function similar to this one and add it to previously mentioned filter hook. E.g.

function hide_wdt_table_tools_buttons( $descObj, $table_id ) {
    if(isset( $descObj->dataTableParams->oTableTools )) {
       foreach( $descObj->dataTableParams->oTableTools['aButtons'] as $index => $button ) {
          if(is_array( $button )) {
             $button_type = $button['sExtends'];
          } else {
             $button_type = $button;
          }

         if( $button_type == 'xls' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'print' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'csv' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'pdf' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }

         if( $button_type == 'copy' ) {
           unset( $descObj->dataTableParams->oTableTools['aButtons'][$index] );
         }
       }

       $descObj->dataTableParams->oTableTools['aButtons'] = array_values( $descObj->dataTableParams->oTableTools['aButtons'] );

   }

   return $descObj;

}

Permalink 0 1

Table settings

How to display table column filters in header?

In order to show column filters in header “Render advanced filter” option needs to be changed to “In the header” on wpDataTables Settings page.

Permalink 1 0

How to show/hide table column filters?

For showing and hiding column filters is responsible “Advanced filtering” settings option on edit table page.
By checking or unchecking this settings check box and saving, table will show or hide column filters.

Permalink 0 1

How to filter table by invisible columns?

If you like to have invisible columns in filters, that can be achieved by enabling “Filter in form” option in table edit page.
“Filter in form” option will create filters as a separate section from the table and additionally show filters for all hidden columns.
Currently there is no option in admin section for hiding unwanted filters from form, but the easiest way that can be done is using CSS.

Permalink 0 2

When I duplicate a table created via Table Constructor and change data in one of them it changes data in all of them.

That feature is designed to duplicate the wpDataTable, it doesn’t duplicate the database table (data source) behind, it creates a copy of the ‘display settings’. It uses same data source and if you change data in one place it will change the values in data source, which will be reflected in all the tables.

Idea behind this is to enable creating multiple tables from same source that would allow presenting same data in different ways.

Permalink 1 1

Never miss new features!

Join 2000+ newsletter subscribers

Never miss notifications about new cool features, promotions, giveaways or freebies - subscribe to our newsletter! We send about one mail per month, and do our best to keep our announcements interesting.

We never spam or disclose your address to anyone.