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 ('WPLANG', '');
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 blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
The rest of this post describes a variety of constants.
| Constant | Description |
|---|---|
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). |
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. |
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. |
WPCF7_SHOW_DONATION_LINK |
When the value of this constant is false (default: true), Contact Form 7 doesn’t show the donation link on its admin panel. If you or your client does not wish to view donation information, set this value false. |
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’. |
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. |
WPCF7_CAPTCHA_TMP_DIR |
When this constant is defined, the value of the constant overrides the setting of directory path of temporary folder for CAPTCHA files. |
WPCF7_CAPTCHA_TMP_URL |
When this constant is defined, the value of the constant overrides the setting of URL of temporary folder for CAPTCHA files. |
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:
- Loading JavaScript and Stylesheet Only When it is Necessary
- Restricting Access to the Administration Panel
- Selectable Recipient with Pipes
- CAPTCHA
- File Uploading and Attachment
