This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: HTML in custom description field

#20691
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Jan,

I see what you mean now, you want to clear the tags from a custom field, that was included via the advanced description field. That is indeed not cleared on purpose, so that anything could be included via the custom fields.
Instead of the previous code, use this one, it is basically the same, except for one line, that will try to clear any tags within the content.

add_filter( 'asp_results', 'asp_get_custom_cf_image', 10, 1 );
function asp_get_custom_cf_image( $results ) {
	$field = 'user-image-url'; // Enter the user meta field containing the image
	foreach ($results as $k=>&$r) {
		if ( $r->content_type == 'user' ) {
                        $r->content = wd_strip_tags_ws($r->content);
			$img = get_user_meta($r->id, $field, true);
			if ( !is_wp_error($img) && !empty($img) )
				$r->image = $img;
		}
	}
	return $results;
}