Controlling behavior by setting constants

Contact Form 7 allows you to control its behavior by setting some constant values.

The typical place to define constants is in the wp-config.php file. You will find that many lines defining constants such as, define('XXX', 'xxx'); exist in the file. You can append new lines after them. Note that your lines must be placed before the last line.

Example (wp-config.php):

define( 'WP_DEBUG', false );

define ( 'WPCF7_LOAD_JS', false ); // Added to disable JS loading
define ( 'WPCF7_LOAD_CSS', false ); // Added to disable CSS loading

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

The rest of this post describes a variety of constants.

WPCF7_LOAD_JS

When the value of this constant is false (default: true), Contact Form 7 does not load the JavaScript on the front end. When the value of this constant is set as header, Contact Form 7 loads the JavaScript in the header instead of in the footer (default).

See also: Loading JavaScript and stylesheet only when it is necessary

WPCF7_LOAD_CSS

When the value of this constant is false (default: true), Contact Form 7 does not load the CSS stylesheet on the front end.

See also: Loading JavaScript and stylesheet only when it is necessary

WPCF7_AUTOP

When the value of this constant is false (default: true), Contact Form 7 does not apply the “autop” filter to the form content. The “autop” filter replaces double line-breaks with paragraph elements.

WPCF7_USE_PIPE

When the value of this constant is false (default: true), Contact Form 7 disables its “pipe” feature, so that pipe character has no special meaning.

See also: Selectable recipient with pipes

WPCF7_ADMIN_READ_CAPABILITY

The value of this constant holds the minimum capability required for access to the administration panel. The default value is edit_posts.

See also: Restricting access to the administration panel

WPCF7_ADMIN_READ_WRITE_CAPABILITY

The value of this constant holds the minimum capability required for editing contact forms. The default value is publish_pages. Obviously WPCF7_ADMIN_READ_WRITE_CAPABILITY should be stricter than WPCF7_ADMIN_READ_CAPABILITY, as you cannot edit contact forms without accessing the administration panel.

See also: Restricting access to the administration panel

WPCF7_UPLOADS_TMP_DIR

When this constant is defined, the value of the constant overrides the setting of directory path of the temporary folder for uploaded files.

See also: File uploading and attachment

Just another contact form plugin for WordPress. Simple but flexible.

%d bloggers like this: