vapvarun icon

Add and remove filters to allow more tags in group description.

vapvarun | PRO | 06/05/24 11:10:01 AM UTC (Edited) | 0 ⭐ | 777 👁️ | Never ⏰ | []
PHP |

1.11 KB

|

None

|

0 👍

/

0 👎

/**
 * Add and remove filters to allow more tags in group description.
 */
function wbcom_add_remove_group_desc_filters() {
    remove_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
    add_filter( 'groups_group_description_before_save', 'bp_groups_filter_kses', 1 );
}
 
add_action( 'bp_loaded', 'wbcom_add_remove_group_desc_filters');
 
/**
 * Allow additional tags in group description.
 *
 * @param array $tags The current array of allowed tags.
 * @return array The modified array of allowed tags.
 */
function wbcom_allow_extra_group_desc_tags( $tags ) {
    $tags['ul'] = array();
    $tags['ol'] = array();
    $tags['li'] = array();
    $tags['strong'] = array();
    $tags['b'] = array();
    return $tags;
}
add_filter( 'bp_groups_filter_kses', 'wbcom_allow_extra_group_desc_tags' );
 
function display_custom_group_description() {
    if ( bp_is_single_item() && bp_is_groups_component() ) {
        $group = groups_get_current_group();
        echo wpautop( wp_kses_post( $group->description ) );
    }
}
add_action('bp_group_header_meta', 'display_custom_group_description');
 
 

Comments