Could you please correct the code is_admin()

What is a moderator? A custom user role? If yes, then: add_action( ‘init’, ‘blockusers_init’ ); function blockusers_init() { if ( is_admin() && (!current_user_can( ‘administrator’ ) || !current_user_can( ‘moderator’ ) ) && ! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) { wp_redirect( ‘http://madeeasy-online.com/zhile-2/dobavit-obyavlenie/’, 302); exit; } }

Make WordPress process admin group comments using $allowedtags

kses_init is hooked onto the init hook with default priority, and (after first removing any of the kses filters) adds filters which strip out tags (wp_filter_post_kses for posts and wp_filter_kses for comments) if the user does not have the capability ‘unfiltered_html’. Since the capability determines whether or not the user can post ‘unfiltered_html’ comments and … Read more

preg_replace and comment_form_defaults

You can use regex anywhere you have a string to manipulate. That is basic PHP. There is nothing special about WordPress that changes that. But why use regex when there are other options? As much fun as it is, regex is tricky and easy to get wrong, and there is significant overhead to using it. … Read more

Filtering the Comment Form Allowed Tags

There’s a filter-hook that allows you to run some checking before comment is posted so you could use it too : add_filter(‘preprocess_comment’, ‘wpse_158147_check_new_comment’); function wpse_158147_check_new_comment($commentdata){ $commentdata[‘comment_content’] = preg_replace(“/<tag(.*?)>(.*)<\/tag>/”, “$2″, $commentdata[‘comment_content’]);// or str_replace return $commentdata; } Here “tag” would be stripped (to be replaced here with your specific tag).

Allow all attributes in $allowedposttags tags

I’m pretty sure you have to explicitly name all allowed attributes – just use: $allowedposttags[‘iframe’] = array ( ‘align’ => true, ‘frameborder’ => true, ‘height’ => true, ‘width’ => true, ‘sandbox’ => true, ‘seamless’ => true, ‘scrolling’ => true, ‘srcdoc’ => true, ‘src’ => true, ‘class’ => true, ‘id’ => true, ‘style’ => true, ‘border’ … Read more

Change allowed HTML tags for comments

You are changing the $allowedtags too late. On the last line, add_filter should be called for pre_comment_content instead of comment_post, and also, use different priority, something like this: add_filter(‘pre_comment_content’, ‘custom_allowed_tags_comment’, 9);

How to allow data:image attribute in src tag during post insert?

Thanks to naththedeveloper from StackOverflow. His answer worked for me. Well, this was a nightmare to find, but I think I’ve resolved it after digging through the WordPress code which hooks in through wp_insert_post. Please add this to your functions.php file and check it works: add_filter(‘kses_allowed_protocols’, function ($protocols) { $protocols[] = ‘data’; return $protocols; }); … Read more