> For the complete documentation index, see [llms.txt](https://docs.super-forms.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.super-forms.com/developers/code-examples/global-fields-elements.md).

# Global fields / elements

Let's assume you already created 50 forms, but you now require a hidden field that holds the current page URL.

At the time of writing Super Forms doesn't yet come with a feature that allows you to add a so called `Global field` .&#x20;

However you can easily achieve this with a small function like the one below.

The code will alter the current form elements array and add a new hidden field named `page_url` with the default value set to `{post_permalink}` which retrieves the current page URL.

Of course you can add multiple fields by altering the JSON code below. If you are not sure how to format them, you could create a temporary form in the back-end, add your fields and then view the `[CODE]` tab on the builder page to copy the JSON value.

If you only require this to be fired for specific forms, you can add a condition based on the `$form_id` parameter value.

{% hint style="warning" %}
Place the below code at the bottom of your child theme **functions.php**
{% endhint %}

```php
function f4d_add_hidden_field($value, $form_id, $meta_key, $single){
    $meta_needed = '_super_elements';
    if(isset($meta_key) && $meta_needed===$meta_key){
        // (optional condition: skip forms with the following ID) if($form_id===123 || $form_id===124) return;
        // (optional condition: only alter forms with the following ID) if($form_id!==123 && $form_id!==124) return;
        remove_filter('get_post_metadata', 'f4d_add_hidden_field', 10);
        $value = get_post_meta($form_id, $meta_needed, true);
        $json = '{"tag":"hidden","group":"form_elements","data":{"name":"page_url","email":"Hidden:","value":"{post_permalink}"}}';
        $value[] = json_decode($json, true);
        return array($value);
    }
    // Return original if the check does not pass
    return $value;
}
add_filter('get_post_metadata', 'f4d_add_hidden_field', 10, 4);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.super-forms.com/developers/code-examples/global-fields-elements.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
