# Filters

Our WP Cloud Plugins include a set of WordPress Filters designed to modify data before it is displayed or saved. Filters allow you to intercept and change plugin outputs or values, offering a flexible way to customize functionality. With these filters, you can adjust settings, content, or behavior in a seamless and efficient manner.

## Slugs

The plugin provides several WordPress actions to hook into its functionality. These actions use a `{slug}` placeholder, which you should replace with the slug corresponding to your plugin variant:

* `shareonedrive` for Share-One-Drive **(OneDrive & SharePoint)**
* `useyourdrive` for **Use-your-Drive (Google Drive)**
* `outofthebox` for **Out-of-the-Box (Dropbox)**
* `letsbox` for **Lets-Box (Box)**

For example, the action  `{slug}_render_formfield_data()`, which is applied when rendering a form submission in a form plugin entries overview, would be `useyourdrive_after_module` for **Use-your-Drive.**

{% hint style="warning" %}
All examples below use **useyourdrive** as slug. Make sure you update this for the plugin you are using.
{% endhint %}

## Available filters

### &#x20; <mark style="background-color:orange;">**{slug}\_render\_formfield\_data()**</mark> &#x20;

Fires after a module module has been rendered.

```php
add_filter('useyourdrive_render_formfield_data', 'render_formfield_data', 10);

function render_formfield_data($data, $ashtml = true){

    // Read the array of files stored in the submission
    $uploaded_files = json_decode($data, true);
    
    // Continue if we aren't receiving any files
    if (empty($uploaded_files) || (0 === count($uploaded_files))) {
        return $data;
    }

    // Render a very basic list
    $formated_value = '';
    foreach ($uploaded_files as $file) {
        $formated_value .= basename($file['path'])." ({$file['size']})\r\n";
    }

    return $formated_value;
}
```

### &#x20; <mark style="background-color:orange;">**{slug}\_apply\_placeholders()**</mark> &#x20;

Replaces placeholders with values. You can add your own custom placeholders.

```php
add_filter('useyourdrive_apply_placeholders', 'custom_placeholder', 10, 3);

function custom_placeholder($string_with_placeholders, $context = null, $extra = [])
{
    // $extra['user_data'] contains current WP_User object if available

    // Set placeholders
    $placeholders = [
        '%my_custom_placeholder%' => 'My Value',
        '%another_placeholder%' => 'Another Value',
    ];

    return strtr($string_with_placeholders, $placeholders);
}
```

### &#x20; <mark style="background-color:orange;">**{slug}\_is\_entry\_authorized()**</mark> &#x20;

Check to see if an item has the correct permissions to be displayed in the front end.

```php
add_filter('useyourdrive_is_entry_authorized', 'custom_placeholder', 10, 3);

function is_entry_authorized($is_authorized, $node)
{
    $entry = $node->get_entry();

    // Skip entry if its a dir or has the PHP extension
    if ($node->is_dir() || 'php' === $entry->get_extension()) {
        return false;
    }

    return $is_authorized;
}
```

{% hint style="info" %}
This information is still being completed...
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://wpcloudplugins.gitbook.io/docs/developers/filters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
