WordPress Block Author to make link on Post

WordPress Block Author to make link on Post

This script aims to block users with the role of author so that they cannot create links or backlinks.

ok just do it first edit /wp-content/themes/yourtheme/functions.php

This Code for Block All User, including administrator

for all role :

function restrict_links_in_posts($content) {
// Remove all tags
$content = preg_replace(‘/]*>.*?<\/a>/i’, ”, $content);
return $content;
}
add_filter(‘the_content’, ‘restrict_links_in_posts’);

And this Code for block only author only

for author only :

function restrict_links_in_author_posts($content) {
if (current_user_can(‘author’)) {
// Remove all tags
$content = preg_replace(‘/]*>.*?<\/a>/i’, ”, $content);
}
return $content;
}
add_filter(‘the_content’, ‘restrict_links_in_author_posts’);

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *