How Can We Help?
You are here:
Print

Custom Functions

With Custom Functions feature, you can include your custom PHP functions to your website without the need to access php files or use FTP.

You can simply paste your code in the CodeMirror field in WP BASE → Tools → Custom Functions page.

When you click Save Custom Functions button, your code will be temporarily “include”d to check if it has compile errors. If no errors are met, it will be executed from that time on. If errors are found, your code will be saved, but it will not be executed.

This is the same method as WordPress does to check before activating a plugin.

Please note that some errors only occur in runtime. It is not possible to catch such errors during this check.

Custom functions feature can be completely disabled by adding this line of code in wp-config.php:
define("WPB_DISABLE_CUSTOM_FUNCTIONS", true);

Or if you want execution of the codes, but prevent editing you can use this line instead:
define("WPB_DISABLE_EDITING_CUSTOM_FUNCTIONS", true);

Custom Functions allows adding your own PHP codes

Custom functions are essentially intended for WP BASE hooks to modify functionality and display on front end, but you can use it with standard WordPress actions and filters too. In that case, you should account for custom functions being executed at wp_loaded action with priority 1000. Therefore you can only use hooks which will be triggered after that. See this post for WordPress action sequence. For example, you cannot use a function triggered with init action.

Table of Contents