Hello,
I added a URL type field in the member profile, but I can’t manage to customize the text for the link and hide the full URL…
I tried something like :
<a href="https://mywebsite.com/test_customized_link/">URL is now hidden</a>
But it doesn’t work, it shows all the text not the link customized.
Is there is a way to customize it please, it’s not really nice to show a full URL like that in a profile field.
I want this result : URL is now hidden
Thank you for your help
Wordpress version : 6.0.1
BuddyPress version : 10.3.0
Website URL : Private website closed for public peopleHello Lobo,
Thank you for posting. Please use the following code to filter all URL field values you can restrict it using field id given as function argument.
add_filter( 'bp_get_the_profile_field_value', function ( $field_value, $field_type, $field_id ) { if ( ! bp_is_user() ) { return $field_value; } $user_id = bp_displayed_user_id(); // You can play with user id. if ( 'url' == $field_type ) { $field_value = sprintf( '<a href="%s">%s</a>', esc_url( 'https://mywebsite.com/test_customized_link/' ), esc_html__( 'URL is now hidden' ) ); } return $field_value; }, 10, 3 );
Regards
RaviHello again,
Sorry, it doesn’t work, I was wrong, the text is showing like that if I choose text field type : <a
href="https://mywebsite.com/test_customized_link/">URL is now hidden</a>
But if I choose a URL field type, I have an error and the field is not saved with the provided value.
I tried to modify your code like this by modifying
if ( 'url' == $field_type )
toif ( 'text' == $field_type )
but it still doesn’t work.And just to clarify, I just want that all URL fields are not filtered and interpret HTML code, for all users, don’t want to specify anything in parameter if possible.
Thank you
Since it will be a private website and fields are accessible only to logged on users, no security problems, everyone on this website are trustful people.
- This reply was modified 2 years, 6 months ago by lobo.
You must be logged in to reply to this topic.