Search code examples
wordpressbuddypress

xprofile_allowed_tags not accepting unordered list


Im trying to get my Budypress site to work with wp_editor on profile fields. So far everything is ok but my tags are being striped.

I added the following:

add_filter( 'xprofile_allowed_tags', 'custom_xprofile_allowed_tags' );

function custom_xprofile_allowed_tags($tags){

$tags['li'] = array();
$tags['ul'] = array(
'type' => true  
);  

return $tags;

}

But it still saving my profile field without <ul><li>

I know the filter is working because if i add unset($tags['strong']); the strong tag is stripped.

Thanks for the help


Solution

  • My code was working fine i didn't realize that i also need to change filter for displaying the data. So my code is :

    function xprofile_with_html() {
        //change allowed tags to use the same as posts when save
        add_filter( 'xprofile_allowed_tags', 'custom_xprofile_allowed_tags',0 );
    
        //remove wp_filter and add custom one when showing in edit field
        remove_filter( 'bp_get_the_profile_field_edit_value',      'wp_filter_kses',       1 );
        add_filter( 'bp_get_the_profile_field_edit_value', 'my_custom_profile_filter',0,3 );
    
    }
    add_action( 'bp_init', 'xprofile_with_html' );
    
    function custom_xprofile_allowed_tags($tags){
    
        global $allowedposttags;
        return $allowedposttags;
    
    }
    
    function my_custom_profile_filter($data){
    
        return xprofile_filter_kses($data);     
    
    }
    

    With these i can use wp_editor for my xprofile fields