Title: Warning: call_user_func_array()
Last modified: January 25, 2023

---

# Warning: call_user_func_array()

 *  Resolved [redactionseomdri](https://wordpress.org/support/users/redactionseomdri/)
 * (@redactionseomdri)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/warning-call_user_func_array-48/)
 * Hello there, I did put a code in my function.php to install Google GTM. Here 
   is the code
 *     ```wp-block-code
       function gtm_head(){
         ?>
           <!-- Google Tag Manager -->
       <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
       new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
       j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
       'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
       })(window,document,'script','dataLayer','GTM-XXXXXX');</script>
       <!-- End Google Tag Manager -->
           <!-- End Google Tag Manager -->
         <?php
       }
       add_action( 'wp_head', 'gtm_head', 1 );
   
       /**
        * Google Tag Manager script in <body> 
        */
       function gtm_body_open(){
         ?>
         <!-- Google Tag Manager (noscript) -->
       	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
       	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
       	<!-- End Google Tag Manager (noscript) -->
         <?php
       }
       add_action( 'wp_body_open', ' gtm_body_open', 1 );
       ```
   
 * But now there’s a line of error on my front website : **Warning**: call_user_func_array()
   expects parameter 1 to be a valid callback, function ‘ gtm_body_open’ not found
   or invalid function name in **/home/u161678441/domains/michaeldri.com/public_html/
   blog/wp-includes/class-wp-hook.php** on line **308**
 * I looked in the class-wp-hook file but I don’t know what to do…. Since i’m not
   a pro in development… Here the section of code in the file :
 *     ```wp-block-code
       // Avoid the array_slice() if possible.
       				if ( 0 == $the_['accepted_args'] ) {
       					$value = call_user_func( $the_['function'] );
       				} elseif ( $the_['accepted_args'] >= $num_args ) {
       					$value = call_user_func_array( $the_['function'], $args );
       				} else {
       					$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int) $the_['accepted_args'] ) );
       				}
       			}
       		} while ( false !== next( $this->iterations[ $nesting_level ] ) );
   
       		unset( $this->iterations[ $nesting_level ] );
       		unset( $this->current_priority[ $nesting_level ] );
   
       		$this->nesting_level--;
   
       		return $value;
       	}
       ```
   
 * Please can you tell me what to do with that ? 🙁 🙁 🙁
 * What should I add ?
 * I would be really thankful !!!
    -  This topic was modified 3 years, 4 months ago by [redactionseomdri](https://wordpress.org/support/users/redactionseomdri/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fwarning-call_user_func_array-48%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/warning-call_user_func_array-48/#post-16408662)
 * The error is not in `class-wp-hook.php`. The error is caused by using `add_action()`
   with a callback that doesn’t exist. The message appears in `class-wp-hook.php`
   because that’s where it’s trying to run the callback.
 * The specific reason you’re seeing this error is that you have an extra space 
   here:
 *     ```wp-block-code
       add_action( 'wp_body_open', ' gtm_body_open', 1 );
       ```
   
 * In front of `gtm_body_open`. Remove that and the error should go away.
 *  Thread Starter [redactionseomdri](https://wordpress.org/support/users/redactionseomdri/)
 * (@redactionseomdri)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/warning-call_user_func_array-48/#post-16408702)
 * Ok now I feel dumb…
 * Thank you ! Resolved

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

The topic ‘Warning: call_user_func_array()’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [redactionseomdri](https://wordpress.org/support/users/redactionseomdri/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/warning-call_user_func_array-48/#post-16408702)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
