WordPress Author role cannot add video code _php tutorial

Source: Internet
Author: User
There has been a very strange situation, is in WordPress can not add video code, specifically in the background editor text mode after adding video code, switch to the visual can see the video frame, but save the video code message.

Careful observation reveals that authors cannot add, while editors and administrators can add.

No appetite, first of all. Solution: To put it simply, install a plugin "User Role Editor", the "Do not filter HTML tags" under the role of the author Hook.

Here is the toss-up process:

1. Debug, find the following sequence of code calls:

Wp_update_post->

Wp_insert_post->

Sanitize_post->

Sanitize_post_field->

2.< span="">

< span="">

< span="">Content_save_pre.

< span="">

Wp_filter_post_kses ');.

< span="">

< span="">

function Kses_init () {
Kses_remove_filters ();

if (current_user_can (' unfiltered_html ') = = False)
Kses_init_filters ();
}

Add_action (' init ', ' kses_init ');
Add_action (' Set_current_user ', ' kses_init ');

At this time the discovery is belong to the current user does not have unfilter_html this permission.

Solution Solutions

1. Try to get rid of this wp_filter_post_kses using function Remove_filter, but there is a add_filter and remove_filter relationship problem, but I add the place remove_ Filter even before add_filter.

This way, even if you find a clever place to add the remove, too dependent on this relationship, to protect no one out of great trouble.

2. Directly to the user to assign pre-unfilter_html permissions, this is a disadvantage is to Kses_init_filters in a series of functions are deleted. Considering that this is their own blog, the author is a number of designated people, and this solution is easy to understand, not so much around, decided to use this method.

WordPress is really powerful, and really enough to toss people.

http://www.bkjia.com/PHPjc/440311.html www.bkjia.com true http://www.bkjia.com/PHPjc/440311.html techarticle There has been a very strange situation, that is, in WordPress can not add video code, specifically in the background editor text mode after adding video code, switch to the visualization can see the normal ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.