Title: Uncaught Error: Call to undefined function
Last modified: December 7, 2016

---

# Uncaught Error: Call to undefined function

 *  Resolved [pglock](https://wordpress.org/support/users/pglock/)
 * (@pglock)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/uncaught-error-call-to-undefined-function/)
 * I’ve recently started using code snippets as I have several functions I want 
   to reuse across my site and I want a simple way of managing them all.
    I created
   two simple functions to take a userid and return a sum of scores from sets of
   questions that user has answered. That total scores are used in a report. This
   was all originally in a functions.php file and working OK.
 * I’ve created the report as a snippet. If I run the function code for the scores
   within the report snippet, it works fine. If I attempt to break the scoring function
   out into a separate snippet and then call it from the report I get
    `Uncaught
   Error: Call to undefined function bg_cost_of_breach()’ Any idea what I’m doing
   wrong?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/uncaught-error-call-to-undefined-function/#post-8532596)
 * It’s possible that the snippet where you use the function is being evaluated 
   after the snippet where you define the function. To remedy this, you could try
   wrapping your use of the function in an action hook:
 *     ```
       add_action( 'init', function () {
             bg_cost_of_breach(); // do something with your function
       } );
       ```
   
 * By using the `init` hook, the function should have already been defined before
   it is called.

Viewing 1 replies (of 1 total)

The topic ‘Uncaught Error: Call to undefined function’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/uncaught-error-call-to-undefined-function/#post-8532596)
 * Status: resolved