# \[c++] Registering Metadata Tags

## The Manual Method

The manual method to declare Metadata Tags can be found in the Project Settings:

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2Fz2CgwDPpOalAyrmIIIda%2Fimage.png?alt=media&#x26;token=b8398586-c64a-46ab-a85a-a727ff1c4084" alt=""><figcaption></figcaption></figure>

Any tags added to this list will be registered as valid asset metadata we can use in the editor and with any tools we create.&#x20;

***

## Programmatically Registering Metadata

When creating tools for Unreal we can sometimes find ourselves wanting to add new metadata tags. Unfortunately, there aren't any options available in the Unreal Python API to register Metadata Tags to the Asset Registry - we'll have to expose this in C++

***

## The C++ Function Method

The following is a C++ header / cpp file function that will allow us to register metadata tags to the Asset Registry. It is also available in the Sample Plugin provided on Github for the Unreal Python Recipe Book:

{% @github-files/github-code-block url="<https://github.com/bralkor/unreal_python_recipe_book/tree/5.2/unreal_plugin/PythonRecipeBook>" %}

### The C++ Code

The code below can be added to a c++ Blueprint Function Library class.&#x20;

The .h code:

```cpp
    /**  Add new metadata tag names to the Asset Registry
     * @param  Tags  the metadata tags to add
     */
    UFUNCTION(BlueprintCallable, Category = "Python | Utils")
    static void RegisterMetadataTags(const TArray<FName>& Tags);
```

The .cpp code:

```cpp
void
UPythonUtilsLibrary::RegisterMetadataTags(const TArray<FName>& Tags)
{
    TSet<FName>& GlobalTagsForAssetRegistry = UObject::GetMetaDataTagsForAssetRegistry();
    for (FName Tag : Tags)
    {
        if (!Tag.IsNone())
        {
            if (!GlobalTagsForAssetRegistry.Contains(Tag))
            {
                GlobalTagsForAssetRegistry.Add(Tag);
            }
        }
    }
}
```

{% hint style="info" %} <mark style="color:yellow;">Note</mark>: `PythonUtilsLibrary` is used in the Sample Plugin for the BP Function Library class name, but you can use another class name as desired
{% endhint %}

### Calling it in Python

With our c++ function compiled and the Plugin enabled, we can use the following logic to call it:

```python
unreal.PythonUtilsLibrary.register_metadata_tags(["a", "b", "c"])
```

{% hint style="info" %} <mark style="color:yellow;">Note</mark>:  `PascalCase` and `camelCase` c++ function names automatically convert to `snake_case` in Unreal Python. This is done to be more pythonic, it's a good reminder to be careful when going between c++ and Python in Unreal.
{% endhint %}
