Title: call_user_func_array() expects parameter 1 to be valid.. Custom Function
Last modified: August 31, 2016

---

# call_user_func_array() expects parameter 1 to be valid.. Custom Function

 *  Resolved [Devin Blewitt](https://wordpress.org/support/users/devinblewitt/)
 * (@devinblewitt)
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/)
 * Full Warning Message:
    mod_fcgid: stderr: PHP Warning: call_user_func_array()
   expects parameter 1 to be a valid callback, function ‘course’ not found or invalid
   function name in /var/www/vhosts/itonlinelearning.com/httpdocs/wp-includes/plugin.
   php on line 525, referer: [http://www.itonlinelearning.com/landing/xxxx-xxxxx/](http://www.itonlinelearning.com/landing/xxxx-xxxxx/)
 * We have 2 custom post types, ‘course’ and ‘landing’ which have been pushing out
   the above error. We still use these post types so am being super careful of any
   changes.
 * After reading a few threads it seems this may be the code that needs amending:
 *     ```
       add_action( 'admin_init', 'course' );
       register_post_type( 'course',
           array(
               'labels' => array(
                   'name' => __( 'Courses' ),
                   'singular_name' => __( 'Courses' )
               ),
               'public' => true,
               'has_archive' => true,
               'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail'),
           )
       );
       ```
   
 * This code snippet is from our course_taxonomy.php file found in /admin/, the 
   function.php file imports the course_taxonomy.php file.
 * Any feedback would be greatly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-7277759)
 * Hi Devin!
 * Hope you’re having a good day!
 * The error message is letting you what is wrong:
 * >  PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback,**
   > function ‘course’ not found** or invalid function name
 * I did add some emphasis to the part that matters most. What that means is that
   the function `course` is not defined anywhere. Part of that reason is because
   the function `call_use_func_array()` is looking for this function to run. The
   reason this function is looking for that is because when you add a filter or 
   an action you are trying to link a function to that.
 * So, in this case `admin_init` is looking for a function called `course` and because
   it cannot find it, it gives that error.
 * Generally you want to avoid registering shortcodes, post types, or taxonomies
   in a theme. The best way is using a plugin so it won’t be lost when the theme
   is switched.
 * To give a code example, if you wanted to do the above you would do something 
   like:
 *     ```
       add_action( 'admin_init', 'jc_reg_posttype' );
       function jc_reg_posttype() {
         // run my needed code here
       }
       ```
   
 * Hope that helps!
 *  Thread Starter [Devin Blewitt](https://wordpress.org/support/users/devinblewitt/)
 * (@devinblewitt)
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-7277811)
 * Thanks Jose for the feedback.
 * I completely understand, but want to make changes to the code to stop the errors.
   So, would you suggest that I empty the function to;
 *     ```
       add_action( 'admin_init', '' );
       register_post_type( 'course',
           array(
               'labels' => array(
                   'name' => __( 'Courses' ),
                   'singular_name' => __( 'Courses' )
               ),
               'public' => true,
               'has_archive' => true,
               'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail'),
           )
       );
       ```
   
 * If because the call can’t see the function, can I confirm that no code is running
   from that function. If that is the case, removing the function call syntax would
   have no effect on the rest of the theme as it is already not being used.
 * Or do you have other ideas?
 * thanks again for your help.
 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-7277906)
 * Happy to help Devin!
 * >  So, would you suggest that I empty the function to;
 * Not sure if that will work seeing how you are not passing it a _callback function_.
   The second part needs to be a valid function that _you_ create in order to register
   your post type.
 * I’ll leave you with a few helpful links:
 * [https://codex.wordpress.org/Function_Reference/register_post_type](https://codex.wordpress.org/Function_Reference/register_post_type)
   
   [https://developer.wordpress.org/reference/functions/add_action/](https://developer.wordpress.org/reference/functions/add_action/)
   [http://docs.presscustomizr.com/article/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers](http://docs.presscustomizr.com/article/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers)
 *  Thread Starter [Devin Blewitt](https://wordpress.org/support/users/devinblewitt/)
 * (@devinblewitt)
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-7277923)
 * OK, I think I have it.
 * I will need to create a function in the function.php file that will register 
   the post type.
 * This should resolve my error issue, correct ?
 * Thanks.
 *  Thread Starter [Devin Blewitt](https://wordpress.org/support/users/devinblewitt/)
 * (@devinblewitt)
 * [10 years ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-7278006)
 * Adding the function worked !! Thanks Jose

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘call_user_func_array() expects parameter 1 to be valid.. Custom Function’
is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [invalid](https://wordpress.org/support/topic-tag/invalid/)
 * [parameter](https://wordpress.org/support/topic-tag/parameter/)
 * [warning](https://wordpress.org/support/topic-tag/warning/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [mojyjoon](https://wordpress.org/support/users/mojyjoon/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/call_user_func_array-expects-parameter-1-to-be-valid-custom-function/#post-8431231)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
