PDF Embedder Documentation

Documentation, Reference Materials, and Tutorials for PDF Embedder

Get access to
Powerful Features!

Home » Documentation » Advanced Solutions » Smart Tags for Watermarks

Smart Tags for Watermarks

Unlock PDF Embedder watermarks and other powerful features.

Want to make your PDF watermarks more personal and dynamic? Instead of a static text watermark, PDF Embedder lets you display live user data (the viewer’s name, username, or email address) directly on every page of your PDF with smart tags.

This guide covers the built-in smart tags available in the watermark feature and how to register custom smart tags using WordPress filter hooks.


Built-in watermark smart tags

PDF Embedder includes three smart tags ready to use out of the box:

  • {fullname}: displays the viewer’s full name
  • {username}: displays the viewer’s WordPress username
  • {email}: displays the viewer’s email address

Add any of these tags to your watermark text in Settings > PDF Embedder > Watermarks, or pass them through the watermark attribute in your PDF Embedder shortcode.

When a visitor is not logged in, the plugin replaces each tag value with the text “Not logged in” rather than leaving the watermark blank.

Registering Custom Smart Tags

The plugin exposes a two-filter API for adding your own dynamic tags. Both filters must be registered and maintain matching array order, because the plugin pairs tag names to their replacement values by position.

add_filter( 'pdfemb_watermark_var_names', static function( $var_names ) {
	$var_names[] = '{year}';
	return $var_names;
}, 11 );

add_filter( 'pdfemb_watermark_var_values', static function( $var_values ) {
	$var_values[] = date( 'Y' );
	return $var_values;
}, 11 );
Code language: PHP (php)

The first filter, pdfemb_watermark_var_names, registers the tag string. The second, pdfemb_watermark_var_values, returns the replacement value. In this example, {year} outputs the current four-digit year.

Add this code using one of the following methods:

Using WPCode (recommended): Install the free WPCode plugin, go to Code Snippets > Add Snippet, paste the code, and activate it.

Adding to functions.php: Add the code to your active theme’s functions.php file.

Once added, the custom tag is available alongside the built-in tags. Use it in the watermark settings field or in the watermark shortcode attribute.

Frequently Asked Questions

Below are some common questions about watermark smart tags.

Can I register multiple custom tags?

Yes. Add each tag name to the pdfemb_watermark_var_names array and its corresponding value to the pdfemb_watermark_var_values array, keeping the order identical across both filters.

Still have questions? We’re here to help!

Last Modified: