the no follow is added at output, not on saving.
so we need to see if the topic/reply is written by an admin or editor and then remove the filter that does the no-follow
This coded is untested, but should work
add_filter ('bbp_get_topic_content' , 'follow_topic_if_admin' , 10 , 2) ;
function follow_topic_if_admin ($content, $topic_id) {
$user_id = bbp_get_topic_author_id( $topic_id ) ;
$user_meta=get_userdata($user_id);
$user_roles=$user_meta->roles;
$allowed_roles = array('editor', 'administrator');
if( array_intersect($allowed_roles, $user_roles ) ) {
remove_filter( 'bbp_get_topic_content', 'bbp_rel_nofollow', 50 );
}
return apply_filters( 'follow_topic_if_admin', $content, $topic_id );
}
add_filter ('bbp_get_reply_content' , 'follow_reply_if_admin' , 10 , 2) ;
function follow_reply_if_admin ($content, $reply_id) {
$user_id = bbp_get_reply_author_id( $reply_id ) ;
$user_meta=get_userdata($user_id);
$user_roles=$user_meta->roles;
$allowed_roles = array('editor', 'administrator');
if( array_intersect($allowed_roles, $user_roles ) ) {
remove_filter( 'bbp_get_reply_content', 'bbp_rel_nofollow', 50 );
}
return apply_filters( 'follow_reply_if_admin', $content, $reply_id );
}
Add this to your functions file.
Let me know if it works
Thank you, unfortunately just tested it creating a new users with for both admin and editor roles and posting a reply with a link and the nofollow is still there 🙁
Could it be that I have Buddypress activated as well?
Buddypress has this “wp_rel_nofollow_callback() – Callback to add rel=nofollow string to HTML A element.”
*Wouldn’t mind also being able to disable nofollow links for admins on buddypress too.
may well be. you’ll need to post on the buddypress support site for help – I know little of buddypress !
Hey @robin-w Tested but not working 🙁
What can be failing in your idea?
This doesn’t work either 🙁
Remove NoFollow from BBPress Posts
Will have to review the code and what’s going on with that filter nowadays