Skip to content

Instantly share code, notes, and snippets.

@meloniq
Created September 29, 2016 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meloniq/d1e8b506ec262afbeb199eea76f8aa0b to your computer and use it in GitHub Desktop.
Save meloniq/d1e8b506ec262afbeb199eea76f8aa0b to your computer and use it in GitHub Desktop.
Strip all HTML tags from user profile description field
/**
* Strip all HTML tags from user profile description field.
*
* @param int $user_id
*
* @return void
*/
function childtheme_strip_html_from_user_profile_description( $user_id ) {
if ( ! isset( $_POST['description'] ) ) {
return;
}
$user_id = wp_update_user( array(
'ID' => $user_id,
'description' => wp_strip_all_tags( $_POST['description'] ),
) );
}
add_action( 'personal_options_update', 'childtheme_strip_html_from_user_profile_description', 13, 1 );
@cowgill
Copy link

cowgill commented Sep 30, 2016

This would disable ALL html.

// disallow all HTML tags
add_filter( 'pre_user_description', 'wp_filter_nohtml_kses' );

@bertlio
Copy link

bertlio commented Aug 19, 2018

Hi there,
Both solutions aren't working in my case, any there any workarounds please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment