The WordPress author role cannot add video code.

Source: Internet
Author: User

There is always a strange situation, that is, you cannot add videos to Wordpress.CodeAfter you add the video code in the text mode of the background editor, you can switch to the visualization mode to see the video box normally, but save the video code message.

After careful observation, it is found that the author cannot be added, but the editing and administrator can be added.

No appetite. First, let's talk about the solution: simply put it out, install a plug-in "User Role Editor", and check "Do not filter HTML tags" under the author role.

The following is a tossing process:

1. debug, the following code call sequence is found:

Wp_update_post->

Wp_insert_post->

Sanitize_post->

Sanitize_post_field->

 

2.Call in sanitize_post_field

$ Value = apply_filters ("{$ field_no_prefix} _ save_pre", $ value );

Filter calledContent_save_pre.

 

After searching this string, it is loaded in the core function kses_init_filters, as shown below:

Add_filter ('content _ save_pre ','Wp_filter_post_kses');.

It is loaded in kses_init_filters.

It is finally called by the following code:

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, it is found that the current user does not have the unfilter_html permission.

 

Solution

1. TryWp_filter_post_kses is removed using the remove_filter function, but this shows a problem of the sequential relationship between add_filter and remove_filter,I added remove_filter before add_filter.

In this way, even if you find a clever place to add the remove feature, it is too dependent on this successive relationship to ensure that no one is confused.

2. Grant the user the pre-unfilter_html permission directly. The disadvantage is thatKses_init_filterAll the functions in S are deleted. Considering that this is my blog, the author is a designated person, and the solution is easy to understand. If there are not so many bypasses, I decided to use this method.

 

WordPress is so powerful that it is really tough.

Related Article

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.