$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Custom user types getting html sanitized in posts|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Custom user types getting html sanitized in posts

matteradmin9PV0评论

For default user types (admin, editor, etc.) style tags are not stripped from posts when saved. For custom user types, style tags are being stripped.

I've applied filters in my funcitons.php file to prevent stripping, but it's ignored when logged in as a custom user type. I've also directly edited TinyMCE in the wp-includes folder, and even that is ignored.

Here is how the user type is registered in my plugin;

function add_roles_on_plugin_activation_tester() {
add_role( 'tester', ' Tester', array(
    'delete_others_pages' => true,
    'delete_others_posts' => true,
    'delete_pages' => true,
    'delete_posts' => true,
    'delete_private_pages' => true,
    'delete_private_posts' => true,
    'delete_published_pages' => true,
    'delete_published_posts' => true,
    'edit_others_pages' => true,
    'edit_others_posts' => true,
    'edit_pages' => true,
    'edit_posts' => true,
    'edit_private_pages' => true,
    'edit_private_posts' => true,
    'edit_published_pages' => true,
    'edit_published_posts' => true,
    'manage_categories' => true,
    'manage_links' => true,
    'moderate_comments' => false,
    'publish_pages' => true,
    'publish_posts' => true,
    'read' => true,
    'read_private_pages' => true,
    'read_private_posts' => true,
    'unfiltered_html ' => true,
    'upload_files' => true,
    'level_1' => true
) );
}
register_activation_hook( __FILE__, 
'add_roles_on_plugin_activation_tester' );

This occurs on standard post types, and custom post types using ACF ver. 5.7.10 custom fields.

WordPress ver. 4.9.9

For default user types (admin, editor, etc.) style tags are not stripped from posts when saved. For custom user types, style tags are being stripped.

I've applied filters in my funcitons.php file to prevent stripping, but it's ignored when logged in as a custom user type. I've also directly edited TinyMCE in the wp-includes folder, and even that is ignored.

Here is how the user type is registered in my plugin;

function add_roles_on_plugin_activation_tester() {
add_role( 'tester', ' Tester', array(
    'delete_others_pages' => true,
    'delete_others_posts' => true,
    'delete_pages' => true,
    'delete_posts' => true,
    'delete_private_pages' => true,
    'delete_private_posts' => true,
    'delete_published_pages' => true,
    'delete_published_posts' => true,
    'edit_others_pages' => true,
    'edit_others_posts' => true,
    'edit_pages' => true,
    'edit_posts' => true,
    'edit_private_pages' => true,
    'edit_private_posts' => true,
    'edit_published_pages' => true,
    'edit_published_posts' => true,
    'manage_categories' => true,
    'manage_links' => true,
    'moderate_comments' => false,
    'publish_pages' => true,
    'publish_posts' => true,
    'read' => true,
    'read_private_pages' => true,
    'read_private_posts' => true,
    'unfiltered_html ' => true,
    'upload_files' => true,
    'level_1' => true
) );
}
register_activation_hook( __FILE__, 
'add_roles_on_plugin_activation_tester' );

This occurs on standard post types, and custom post types using ACF ver. 5.7.10 custom fields.

WordPress ver. 4.9.9

Share Improve this question edited Jan 30, 2019 at 16:03 Aus-tn asked Jan 30, 2019 at 15:30 Aus-tnAus-tn 71 silver badge5 bronze badges 2
  • 1 unfiltered_html should be giving you that capability. try removing level_1 as that converts to contributor which does no have the unfiltered html cap. I'm making wild guesses here but it's possible that it's overriding your settings. – mrben522 Commented Jan 30, 2019 at 16:13
  • You're right, I was missing unfiltered_html, I tried removing level_1 before but adding unfiltered solved it, if you want, add this as an answer and I'll mark it correct. – Aus-tn Commented Jan 30, 2019 at 18:35
Add a comment  | 

1 Answer 1

Reset to default 2

You need 'unfiltered_html' => true, in your capabilities. you have an extra space in yours.

Post a comment

comment list (0)

  1. No comments so far