Join our new community forum for support & discussion

Join Now

Home Support General HivePress Html-editor for the user profile

Html-editor for the user profile

  • Author
    Posts
  • Efim

    Hello.
    I added this snippet to display the html-editor for the user profile, a toolbar appeared, but when saving and reopening the profile, the text formatting disappears. How to fix it?

    add_filter(
    	'hivepress/v1/models/user',
    	function( $model ) {
    		$model['fields']['description']['editor'] = true;
    		$model['fields']['description']['html'] = true;
    
    		return $model;
    	}
    );
    yevhen developer

    The code snippet seems to be correct, but please note that some advanced HTML tags will be removed anyways. Please try using the formatting options from the editor toolbar (e.g. making the text bold).

    Efim

    <b></b> remains, <ul></ul> is not saved. In listing, this function works correctly

    Efim

    <ul></ul> is not saved.

    yevhen developer

    Sorry, we checked this again and it seems that the profile description in WordPress does not allow HTML (on WordPress level), this requires further customizations (if possible at all). It works with listing descriptions because listings are implemented as posts.

    Efim

    I found a solution

    //removing the filter that does not allow you to enter html tags
    remove_filter('pre_user_description', 'wp_filter_kses');
    
    //adding another filter that allows the use of html tags
    add_filter('pre_user_description', 'wp_filter_post_kses');
    
    add_filter(
    	'hivepress/v1/models/user',
    	function( $model ) {
    		$model['fields']['description']['editor'] = true;
    		$model['fields']['description']['html'] = true;
    
    		return $model;
    	}
    );
    ihor developer

    Thanks for posting the solution!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Html-editor for the user profile’ is closed to new replies.