• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
VdoCipher: Secure Video Hosting for Business

VdoCipher

☰
  • Features
  • Pricing
  • Testimonials
  • About
  • Contact Us
Login
Sign Up

Custom variables as watermark on WordPress videos

January 6, 2023 /

Please visit Add Text to Videos with Watermark for a detailed introduction to adding a watermark to your videos. This particular blog explains what is going on under the hood of the WP plugin, and is useful only if you are adding your own custom-built variables as part of the watermark. Currently, name, IP, and email can be shown as part of the watermark.

Table Of Contents:

  • Default WordPress fields that can be added
  • Custom filter addition to the WordPress hook
  • JSON Code addition to the VdoCipher WordPress Plugin
  • Example Steps to configure custom field “Phone number” as a watermark

Watermark on videos adds extra security for the video from screen capture by adding variables such as email, IP or date information to the videos. Custom variables are now supported in plugin 1.6

Default WordPress fields that can be added

Our plugin has been configured to replace the following strings in the annotation code by default:

  • {name} – Current User display name
  • {email} – Current User email
  • {username} – Current User Login
  • {id} – Current User ID

Till version 1.5 of our WordPress plugin, watermark on videos could only have a limited number of dynamic variables. With version 1.6, we have now added filter hooks on the annotation code to enable other plugins or themes to change the annotation code.

Custom filter addition to the WordPress hook

You can now add a custom filter to the hook `vdocipher_annotate_preprocess` . Example code for adding custom filter is:

function customfunc($vdo_annotate_code){
 $customVariable = "Hello world";
 $vdo_annotate_code = str_replace('{var1}', $customVariable, $vdo_annotate_code);
 return $vdo_annotate_code;
}

add_filter('vdocipher_annotate_preprocess', 'customfunc');

Display WordPress Default field like User Fullname

An example code to display the full name is as follows:

function customvdofunc($vdo_annotate_code){
    $fullname = "";
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $firstname = $current_user->user_firstname;
        $lastname = $current_user->user_lastname;
        $fullname = $firstname . " " . $lastname;
     }
     $vdo_annotate_code = str_replace('{fullname}', $fullname, $vdo_annotate_code);
     return $vdo_annotate_code;
}
add_filter('vdocipher_annotate_preprocess', 'customvdofunc');

This would replace the string ‘{fullname}’ in the watermark code to the fullname of the logged in user.

JSON Code addition to the VdoCipher WordPress Plugin

The above code enables you to replace the token {var1} with the value of $customVariable. You can then use an annotation code like:

[
{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'{var1}', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}
]

This code on going through the above filter will become

[
{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'Hello world', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}
]

This function can be placed in the functions.php file in your theme. It is recommended to create a child theme before making such edits.

Example Steps to configure custom field “Phone number” as a watermark

You can configure user-specific details like “phone numbers” as a watermark using the VdoCipher WordPress plugin annotation field and add_filter function in the functions file. shortcode embedded in WordPress.

Note: This phone number is a Custom Field created for illustration using a  plugin named “Advanced Custom Fields” and the name for this custom field is phone_number. You might not need to configure such custom fields, your membership plugin that you might be using would already have such custom field addition functionality. The phone number addition of a user on their profile needs to be managed and taken care of from your WordPress setup side. Your WordPress developers can check and implement it. For this example, the sample WordPress viewer playing the video has the phone number  887788778877 on his profile.

custom variables like phone number addition in wordpress user profile

custom field phone number addition via plugin

Below is a code demonstrating the usage of a sample function for displaying the saved phone number as a watermark and plugin setup.

Additions in functions.php WordPress file

  1. Login to your WordPress account having theme editor access.
  2. Open functions.php through Appearance>Theme File Editor or Tools>Theme File Editor
  3. Add given below custom PHP function in the functions.php file and save the file.
function customvdofunc($vdo_annotate_code){
   $Phonenumber = "";
   if (is_user_logged_in()) {
       $current_user = wp_get_current_user();
       $PNO = $current_user->phone_number;
          }
    $vdo_annotate_code = str_replace('{Phonenumber}', $PNO, $vdo_annotate_code);
    return $vdo_annotate_code;
}
add_filter('vdocipher_annotate_preprocess', 'customvdofunc');

Additions in functions php WordPress file

Adding JSON to the VdoCipher WordPress Plugin field

You need to add the following JSON code in the plugin settings to call the custom function and display the viewer’s phone number as a watermark.


[{"type":"rtext", "text":"{Phonenumber}", "alpha":"0.90","color":"#FFFF00","size":"12","interval":"5000","skip":5000}]

Adding JSON to the VdoCipher WordPress Plugin field

On playback of the videos, the watermark will show the phone number of the viewer playing the video. Similarly, you can call other custom or WordPress data fields via functions.php and display the same by adding more lines of JSON code in the VdoCipher plugin field.

watermark showing the phone number of the viewer playing the video

Supercharge Your Business with Videos

At VdoCipher we maintain the strongest content protection for videos. We also work extremely hard to deliver the best viewer experience. We'd love to hear from you, and help boost your video streaming business.

Free 30-day trial →

Filed Under: Technology, Using VdoCipher, Watermark, WordPress Tagged With: custom watermark video, wordpress secure streaming, wordpress watermark

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Secure Your Videos

Blog Categories

  • DRM 
  • APIs and Sample Codes
  • WordPress
  • E-learning
  • Media
  • Video Tech
  • Portuguese
  • Spanish
  • Arabic

Popular Posts

  • Google Widevine DRM 
  • WordPress video plugin: Add Secure Videos to your WP site
  • Understanding Video Quality – Pixels (p), Bitrate (kbps), Aspect Ratios
  • Add text to video with dynamic watermarking
  • Encrypted Video Streaming: VdoCipher & Others
  • Video Hosting For Online Courses
  • Video Quality: What is Video Bitrate, Pixel & Aspect Ratios 
  • Online Video Player
  • Apple Fairplay DRM
  • Study Apps For Students
  • SVOD VS TVOD VS AVOD
  • DRM Security
  • Exoplayer Tutorial
  • Video Platform Comparison

Recent Top Post

  • Enterprise Video Platform
  • Cloud Video Platform
  • Shaka Player
  • Install FFMPEG on Windows
  • Video Aspect Ratio
  • Video Streaming Protocols
  • Adaptive Bitrate Streaming
  • Elearning Statistics 2021
  • DRM Solution
  • Video Bitrate
  • History Of Youtube
Recent Blogs
  • Guide to Video in WordPress with Embed, Gallery & Player Plugin etc
  • Best WordPress Video Hosting Plugin & issues with Self Hosting
  • Custom variables as watermark on WordPress videos
  • History of YouTube – How it All Began & Its Rise
  • Best Video Streaming Hosting Service Providers in 2023
  • Секреты видеохостинга: Как монетизировать ваши видео
  • Топ-7 платформ онлайн-видеохостинга для онлайн-курсов
  • Sharing Private Video Securely with Encrypted Upload and Streaming
Popular Blogs
  • How many use easy video download piracy tools ?
  • Quickest Way to Start Your Video Selling Site
  • WordPress course plugin to make course website – Sensei tutorial
  • VdoCipher package Workflow and demo – Secure video streaming
Navigation
  • Home
  • Glossary
  • Features
  • About Us
  • Pricing
  • FAQs
  • Terms
  • Privacy Policy
  • Contact US
Industry
  • Education and Training
  • Media and Entertainment
  • DRM and Antipiracy
  • APIs for Developers
  • Video Hosting and Marketing
Follow Us
We are Amazon AWS Technology Partner for Secure Video Hosting for Business
We use Akamai CDN for Secure Video Streaming for Business

© 2023 VdoCipher Media Solutions Pvt. Ltd.