UnderHost
Knowledgebase Docs

Undefined function error: function not defined

Fix "Call to undefined function" when function file not loaded, plugin inactive, or extension missing.

On this page

"Call to undefined function" means your code tried to use a function that doesn't exist or hasn't been loaded yet. This usually happens when: a required file wasn't included, a plugin isn't active, or a PHP extension is missing.

Function file not loaded

If you created a custom function, the file containing it must be loaded before the function is called.

Common mistake:

<?php
echo my_custom_function();  // Function defined below, but not yet loaded!

function my_custom_function() {
  return "Hello";
}
?>

Fix: Define the function before using it, or load it from a separate file:

<?php
require_once('functions.php');  // Load custom functions first
echo my_custom_function();  // Now it's safe to use
?>

WordPress plugin is inactive

If a plugin provides a function and you call it without checking if the plugin is active:

<?php
// This fails if my_plugin is not active
echo my_plugin_function();
?>

Fix: Check if the function exists before calling it:

<?php
if (function_exists('my_plugin_function')) {
  echo my_plugin_function();
} else {
  echo "Plugin not active";
}
?>

PHP extension not installed

Some functions require PHP extensions (like curl_init requires the CURL extension).

Fix: Check which extensions are loaded:

<?php
if (extension_loaded('curl')) {
  echo "CURL is installed";
} else {
  echo "CURL is missing - contact hosting to install it";
}
?>

Or check in cPanel → Select PHP Version → Extensions. Make sure required extensions are enabled.

Troubleshooting checklist

  • ☐ Check the error message - it shows exactly which function is undefined
  • ☐ Verify the function is spelled correctly (case-sensitive)
  • ☐ Check if the file containing the function is being included/required
  • ☐ For WordPress: verify the plugin providing the function is active
  • ☐ Check if the required PHP extension is enabled
  • ☐ Check PHP version requirements - older PHP may not have the function
Enable WP_DEBUG for better error messages

In WordPress, enable WP_DEBUG in wp-config.php to see exactly which function is missing and what called it.

Related: Fatal PHP errors | WordPress troubleshooting

Was this article helpful?

Still troubleshooting?

Use UnderHost tools for quick checks, or open a support ticket when the issue needs account or server access.

Related articles

Back to Troubleshooting