Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › HTML in custom description field › Reply To: HTML in custom description field
January 9, 2019 at 1:25 pm
#20691
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;
}