# Too few arguments error when adding action

**URL:** <https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760>\
**Category:** HivePress\
**Tags:** code\
**Created:** [September 10, 2022, 3:27am UTC](https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760 "2022-09-10T03:27:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggazzano](https://community.hivepress.io/user_avatar/community.hivepress.io/ggazzano/32/1605_2.png) [@ggazzano](https://community.hivepress.io/u/ggazzano)\
**Post date:** [September 10, 2022, 3:27am UTC](https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760/1 "2022-09-10T03:27:49Z")

</div>

Adding the following code to functions.php:

```auto
add_action('hivepress/v2/models/user/update', function($user_id, $user ) {

});

```

And then updating any field in User Settings screen raises the following error:

**Fatal error** : Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /home/public\_html/dev/wp-includes/class-wp-hook.php on line 309 and exactly 2 expected in /home/public\_html/dev/wp-content/themes/listinghive/functions.php:53  
Stack trace:  
#0 /home/public\_html/dev/wp-includes/class-wp-hook.php(309): {closure}(27)  
#1 /home/public\_html/dev/wp-includes/class-wp-hook.php(331): WP\_Hook-\>apply\_filters(‘’, Array)  
#2 /home/public\_html/dev/wp-includes/plugin.php(476): WP\_Hook-\>do\_action(Array)  
#3 /home/public\_html/dev/wp-content/plugins/hivepress/includes/components/class-hook.php(131): do\_action(‘hivepress/v2/mo…’, 27, Object(HivePress\Models\User))  
#4 /home/public\_html/dev/wp-includes/class-wp-hook.php(309): HivePress\Components\Hook-\>update\_us in **/home/public\_html/dev/wp-content/themes/listinghive/functions.php** on line **53**

The same error occurs with:  
add\_action(‘hivepress/v1/models/user/update\_first\_name’, function($object\_id, $value ) {

});

**Fatal error** : Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /home/public\_html/dev/wp-includes/class-wp-hook.php on line 309 and exactly 2 expected in /home/public\_html/dev/wp-content/themes/listinghive/functions.php:60  
Stack trace:  
#0 /home/public\_html/dev/wp-includes/class-wp-hook.php(309): {closure}(27)  
#1 /home/public\_html/dev/wp-includes/class-wp-hook.php(331): WP\_Hook-\>apply\_filters(‘’, Array)  
#2 /home/public\_html/dev/wp-includes/plugin.php(476): WP\_Hook-\>do\_action(Array)  
#3 /home/public\_html/dev/wp-content/plugins/hivepress/includes/components/class-hook.php(175): do\_action(‘hivepress/v1/mo…’, 27, ‘vvvvvvvsssssss’)  
#4 /home/public\_html/dev/wp-includes/class-wp-hook.php(307): HivePress\Components\Hook-\>update\_user\_meta(‘816’ in **/home/public\_html/dev/wp-content/themes/listinghive/functions.php** on line **60**

---

<div class="post-metadata">

**Author:** ![ihor](https://community.hivepress.io/user_avatar/community.hivepress.io/ihor/32/5_2.png) [@ihor](https://community.hivepress.io/u/ihor)\
**Post date:** [September 10, 2022, 3:03pm UTC](https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760/2 "2022-09-10T15:03:25Z")

</div>

If a custom callback you assign to a hook contains more than 1 parameter please specify the number of parameters this way:

```auto
add_action(‘hivepress/v2/models/user/update’, function($user_id, $user ) {

}, 10, 2);

```

> **[add\_action() | Function | WordPress Developer Resources](https://developer.wordpress.org/reference/functions/add_action/)**
>
> Adds a callback function to an action hook.

---

<div class="post-metadata">

**Author:** ![ggazzano](https://community.hivepress.io/user_avatar/community.hivepress.io/ggazzano/32/1605_2.png) [@ggazzano](https://community.hivepress.io/u/ggazzano)\
**Post date:** [September 11, 2022, 4:10am UTC](https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760/3 "2022-09-11T04:10:48Z")

</div>

Thanks ihor!

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [October 11, 2022, 4:11am UTC](https://community.hivepress.io/t/too-few-arguments-error-when-adding-action/1760/4 "2022-10-11T04:11:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
