bp_get_profile_field_data returns additional markup for email and website fields
-
Hello,
I noticed recently that the HTML5 Website and Email fields are returning with markup when called through the bp_get_profile_field_data function. This is conflicting with the link wrapping markup I have in place. My desire is to have just the email/web address returned as plain text as the method does for text fields.
I noticed in the plugin code that this function is being intercepted with a filter:
add_filter( 'xprofile_get_field_data', array($this, 'bxcft_get_field_data'), 10, 2 );
And that it’s returning the markup for these fields:
public function bxcft_get_field_data($value, $field_id) { $field = new BP_XProfile_Field($field_id); $value_to_return = strip_tags($value); if ($value_to_return !== '') { ... // Email. elseif ($field->type == 'email') { if (strpos($value_to_return, 'mailto') === false) { $value_to_return = sprintf('<a href="mailto:%s">%s</a>', $value_to_return, $value_to_return); } } // Web. elseif ($field->type == 'web') { if (strpos($value_to_return, 'href=') === false) { $value_to_return = sprintf('<a href="%s">%s</a>', $value_to_return, $value_to_return); } } ... } return apply_filters('bxcft_show_field_value', $value_to_return, $field->type, $field_id, $value); }
I was able to strip this markup from my template using the strip_tags php function,
strip_tags(bp_get_profile_field_data('field='.$fields['email'].'&user_id='.$user_id));
but would prefer if I could simply disable this behaviour in the plugin.Much appreciated,
Cheershttps://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/
- The topic ‘bp_get_profile_field_data returns additional markup for email and website fields’ is closed to new replies.