ACF Table Field Pro Add-on Docs Last updated:

Since version: v1.8.0

Release Candidate 1.8.0-RC1

This page documents version 1.8.0, which is available as Release Candidate 1.8.0-RC1 for manual installation. The current public version is 1.7.6, automatic plugin updates still deliver that version.

Download the Release Candidate from your account (Download the plugin) and install it manually (Install the plugin). Details may still change until the final release.

Filter acf_tablefield/shortcode/enabled

New since version 1.8.0

This filter is new.

This filter decides whether the shortcode [tablefieldpro] outputs a table. The default is the setting Enable the shortcode [tablefieldpro] (ACF → Table Field Pro, tab Features), which is off for new installs since 1.8.0, see Enable or disable the shortcode. The filter runs on every shortcode, so it can decide per field or post. When it returns false, the shortcode outputs an empty string.

Parameters

add_filter( 'acf_tablefield/shortcode/enabled', '__return_true' );
    • $enabled
    • (bool)
    • true outputs the table, false outputs an empty string.

    • Defaults: The setting Enable the shortcode [tablefieldpro], off for new installs.
    • $atts
    • (array)
    • The attributes of the shortcode: field, subfield, post_id and table_class. Attributes that are not given are false.

Example: only for some fields

add_filter( 'acf_tablefield/shortcode/enabled', function( $enabled, $atts ) { 
 
	if ( in_array( $atts['field'], array( 'price_table', 'opening_hours' ), true ) ) { 
		return true; 
	} 
 
	return $enabled; 
}, 10, 2 );

With the setting off, only the listed field names are allowed.

Example: only tables of the current post

add_filter( 'acf_tablefield/shortcode/enabled', function( $enabled, $atts ) { 
 
	if ( false === $atts['post_id'] || (string) get_the_ID() === (string) $atts['post_id'] ) { 
		return $enabled; 
	} 
 
	return false; 
}, 10, 2 );

This blocks tables of other posts, and also post_id="option".

Security

Anyone who can write shortcodes, for example authors and contributors, can output the table field of any post, page, user, term or options page, also from private posts and drafts, if they know the field name or field key. Only enable it for fields whose content may be shown to everyone who can write posts.

Previous and Next Sources

Parent sources