# Error when I put custom function in admin.php but all is fine if I put the code in functions.php

**URL:** https://discourse.roots.io/t/error-when-i-put-custom-function-in-admin-php-but-all-is-fine-if-i-put-the-code-in-functions-php/14014
**Category:** sage
**Created:** 2018-10-31T07:50:46Z
**Posts:** 2

## Post 1 by @Jimmylet — 2018-10-31T07:50:47Z

Hello everyone,

I would like to add a function in my code. When I add it to “admin.php” or “setup.php”, I get an error

> Warning: call\_user\_func\_array() expects parameter 1 to be a valid callback, function ‘myplugin\_settings’ not found or invalid function name

If I put my function in “functions.php”, it works.

Is there a way to put it in one of the files mentioned above?

Thank you

```
function myplugin_settings() {
   // Add tag metabox to page
   register_taxonomy_for_object_type('post_tag', 'page');
   // Add category metabox to page
   register_taxonomy_for_object_type('category', 'page');
   }
// Add to the admin_init hook of your theme functions.php file
add_action( 'init', 'myplugin_settings' );
```

---

## Post 2 by @blu — 2018-10-31T10:09:46Z

From the docs…

The PHP code in Sage is namespaced, so make sure to [use namespaced functions and classes](https://roots.io/upping-php-requirements-in-your-wordpress-themes-and-plugins/).

try…

`add_action( 'init' , __NAMESPACE__. '\\myplugin_settings' );`
