• yoyo13

    (@yoyo13)


    Hi,

    i search a simple code to insert in fonction.php

    I whant block post buddypress post and comment with link in content just for r?le type. For exemple if a member with “base” r?le comment a link, his post must be blocked but if member with “premium” post a comment or post with link, he can do it without problème.

Viewing 1 replies (of 1 total)
  • graphicscove

    (@graphicscove)

    function restrict_links_for_role($content, $user_id) {

    $user = get_userdata($user_id);

    if (in_array('base', $user->roles)) {

    if (preg_match('/https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/', $content)) {

    bp_core_add_message(__('You cannot post links with your current role.'), 'error');

    return false; // Prevent post/comment from being saved

    }

    }

    return $content;

    }

    add_filter('bp_activity_post_content', 'restrict_links_for_role', 10, 2);

    add_filter('bp_activity_comment_content', 'restrict_links_for_role', 10, 2);

    I have this snippet that might be useful to you. It will search links in the comments from a certain user role.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.