Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

  • patrix87
    Participant

    @patrix87

    I found a more reasonable solution than the original.

    simply authorize img tag everywhere.

    I’m working on allowing it only for the signature field but that will not be easy

    simply add that to your function.php

    // Add img tag to wp_kses filter
    
    function gawd_allowed_tags() {
    	global $allowedtags;
    	$allowedtags['img'] = array( 'src' => array () );
    }
    
    add_action('init', 'gawd_allowed_tags', 10);
    

    patrix87
    Participant

    @patrix87

    Nah I don’t want a plugin to upload a picture. I just want to autorize the img tag inside fields.

    Because most of my users use BF4Stats signature blocks.

    and they look like this :


    patrix87
    Participant

    @patrix87

    *(updating tags)


    patrix87
    Participant

    @patrix87

    I made some “progress”

    I found this and I can agree that it is still true.
    https://buddypress.trac.wordpress.org/ticket/5971
    Filtering is inconsistent and sometime happens twice.

    I think this should be something to look into somewhat soon.

    Anyway here is the minimum you have to do to turn off html filtering.

    BUT it makes you website a lot more vulnerable to attacks and errors so use it at your own risk.

    Add this code to your child theme function.php

    
    //Unfilter xprofile *risky*
    
    remove_filter( 'bp_get_the_profile_field_value',           'xprofile_filter_kses', 1 );
    remove_filter( 'bp_get_the_profile_field_edit_value',      'wp_filter_kses',       1 );
    remove_filter( 'xprofile_get_field_data',                  'wp_filter_kses', 1 );
    remove_filter( 'bp_xprofile_set_field_data_pre_validate',  'xprofile_filter_pre_validate_value_by_field_type', 10, 3 );
    remove_filter( 'xprofile_data_value_before_save',          'xprofile_sanitize_data_value_before_save', 1, 4 );
    
    

    patrix87
    Participant

    @patrix87

    Same problem here,

    I’ve even tried to modify xprofile_filter_kses directly to add img tag without any success.

    Apparently the fields are being filtered more than once.

    here’s my modified code

    function xprofile_filter_kses( $content, $data_obj = null ) {
    	global $allowedtags;
    
    	$xprofile_allowedtags             = $allowedtags;
        $xprofile_allowedtags['a']['img']['rel'] = array();
    
    	$xprofile_allowedtags = apply_filters( 'xprofile_allowed_tags', $xprofile_allowedtags, $data_obj );
    	return wp_kses( $content, $xprofile_allowedtags );
    }
    
Viewing 5 replies - 1 through 5 (of 5 total)
Skip to toolbar