Skip to:
Content
Pages
Categories
Search
Top
Bottom

Allow HTML Attributes in Profile Description Field


  • neilgee
    Participant

    @neilgee

    Hi,

    I am looking at to add attributes in a link tag in the Profile Field description area, I can add a link but if I add another attribute like target it gets stripped on save.

    I have tried…

    
    function descrition_field_remove_html_filter() {
    	remove_filter( 'bp_get_the_profile_field_description', 'wp_filter_kses' );
    }
    add_action( 'bp_init', 'descrition_field_remove_html_filter' );
    

    But that doesn’t fix it.

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

  • danbp
    Participant

    @danbp

    Hi,

    try by adding remove_filter( 'bp_get_the_profile_field_description', 'stripslashes' );


    neilgee
    Participant

    @neilgee

    No doesn’t work either, still strips out the attribute on save. Also tried the to remove wp_filter_kses with a priority of 1– still not working though.


    shanebp
    Moderator

    @shanebp

    Just guessing…

    Try using the bp_ready hook instead of bp_init.

    Try adding the priority to the call:
    remove_filter( 'bp_get_the_profile_field_description', 'wp_filter_kses', 1 );

    Try adding your attributes to the $allowedtags global.
    https://ben.lobaugh.net/blog/201762/add-html-tags-to-the-allowed-tags-list-in-wordpress


    neilgee
    Participant

    @neilgee

    Yes had to get it into $allowedtags – I already had tried the priority and that didn’t work. This link helped – http://ottopress.com/2010/wp-quickie-kses/

    Code I used…

    	add_action( 'init', function () {
    		global $allowedtags;
    	
    			$allowedtags['a'] = array(
    			        'href'   => array (),
    			        'title'  => array (),
    			        'target' => array ()
    			);
    		}
    	);
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar