WordPress does not allow Authors to embed video as iframes i.e. YouTube, Vimeo and Daily Motion videos, etc. As an author, when you try to insert HTML code of a YouTube video, you will find that the code gets removed automatically after you save any changes. This happens because of WordPress’s HTML filtering security feature.
The capability to post video content on WordPress is “unfiltered_html“. This ability is available to Administrators and Editors. In this article, I will share how easily you can an allow your WordPress authors to embed videos in blog posts. While there are several ways you can achieve this task, I will share 2 very easy methods to do this job.
Method 1 – Editing functions.php File
This method needs access to your FTP server. You can use FileZilla or your cPanel’s native File Manager.
Go to your theme files (root/wp-content/themes/[current-theme-name]). Open functions.php and add the following code:
function add_theme_caps() { // gets the author role $a_role = get_role( 'author' ); // This would allow the author to embed videos in WordPress $a_role->add_cap( 'unfiltered_html' ); } add_action( 'admin_init', 'add_theme_caps');
After adding the code, check if it’s working by embedding a video with an Author account. If it works, then come back to the functions.php file and remove the code. The option for ‘unfiltered_html’ will be added to the database. If it doesn’t work for you or you feel it’s a little bit complicated for you then follow step 2.
Step 2 – Using a WordPress Plugin
The second method is even easier than the first. All you need to do is to install a plugin that manages user roles. For this task, I would recommend User Role Editor.
- Install the plugin and activate it
- Go to Users -> User Role Editor
- Select Author from the drop down menu
Scroll down to find ‘unfiltered_html’ . Check this option and hit Update.
That’s it. Now get yourself a chocolate bar and share your experience below in comments.