# Extra Smart Tags for WPForms

> Adds {current_year}, {user_role} and {site_name_plain} smart tags you can use in WPForms notifications, confirmations and default values.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: wpforms, smart-tags, notifications
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpforms-custom-smart-tags/

## Code

```php
add_filter( 'wpforms_smart_tags', function ( $tags ) {
    $tags['current_year']    = 'Current Year';
    $tags['user_role']       = 'User Role';
    $tags['site_name_plain'] = 'Site Name (plain text)';

    return $tags;
} );

add_filter( 'wpforms_smarttags_process_value', function ( $value, $tag_name ) {
    switch ( $tag_name ) {
        case 'current_year':
            return wp_date( 'Y' );
        case 'user_role':
            $roles = is_user_logged_in() ? (array) wp_get_current_user()->roles : array();
            return $roles ? (string) reset( $roles ) : '';
        case 'site_name_plain':
            return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
    }

    return $value;
}, 10, 2 );
```

## Notes

The tags appear in the Smart Tags list of the form builder.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Extra Smart Tags for WPForms" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
