Notifications
Clear all

Limited Support

Dear Clients and Partners, we wish you a Merry Christmas and a Happy New Year! May this season bring you joy, peace, and good times with your loved ones.
Our support will be limited during the holidays, and we will return to full service on January 7.
Thank you for your understanding.
We appreciate your support this year and look forward to working with you in the new year.
Happy Holidays!

 

[Solved] My code is not getting embeded

15 Posts
5 Users
3 Reactions
3,770 Views
Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago

Hi, i am trying to embed a youtube video via code, it show me the video preview in editor but when i post it it shows nothing.

14 Replies
Sofy
Posts: 4911
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi @mrfahadkhan,

Just put this code in active WordPress theme's functions.php:

add_filter('wpforo_content_after', 'wpforo_custom_video_embed', 10);
function wpforo_custom_video_embed( $content ){
$paterns = array();
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$content = preg_replace($paterns, "<iframe width=\"420\" height=\"280\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $content);
return $content;
}

For more advanced embedding options please check out wpForo Embeds add-on:

https://gvectors.com/product/wpforo-embeds/

2 Replies
(@mrfahadkhan)
Joined: 6 years ago

Eminent Member
Posts: 27

I have added this code at the bottom of Functions.php but still my videos are not getting embedded.

Moderator
(@martin)
Joined: 8 years ago

Support Team
Posts: 992

Please click on the [Delete all caches] button in wpForo cache in Dashboard > Forums > Dashboard admin page. Then delete website cache, then navigate to forum home page and press Ctrl+F5. If it doesn't help, leave some example URL, where we can check it.

Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago
1 Reply
Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

@mrfahadkhan, please leave example of your embed URL not the post URL. What have you embedded in this page?

Posts: 27
Topic starter
(@mrfahadkhan)
Eminent Member
Joined: 6 years ago

<iframe width="560" height="315" src="https://www.youtube.com/embed/WddvCQ6Bk0o" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Sofy
Posts: 4911
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi @mrfahadkhan,

You just need to insert the URL without iframe tag, only the < https://www.youtube.com/embed/WddvCQ6Bk0o > part. 

By default, wpForo doesn't allow to use iframe tag, as it is not secure. There can be a lot of spam post.

In Dashboard > Forums > Tools > "Allow extra HTML tags" textarea you should add iframe tag name with its attributes . This will allow using iframe tag  (use the source ( {:} )  button before passing the link).

iframe
Page 1 / 2