0

I am using Wordpress and Buddypress and i am trying to remove or hide the username that is being displayed in the autocomplete field of messages in Buddypress. Tried some tests from this post and also this , but with no luck. Did someone run into this issue?

I was also looking around if i could just hide it with some css, but i think is not possible since the html is like that :

<li class="ac_event ac_over"><span id="link-username" href="#"></span>
<img src="https://www.test.com/wp-content/uploads/avatars/23/user-bpthumb.jpg" style="width: 15px"> &nbsp; User (<strong>U</strong>sername)</li>

and need to remove (<strong>U</strong>sername) I have also tried to remove or add some html span inside the native bp code

'<span id="%s" href="#"></span><img src="%s" style="width: 15px">   %s (%s)' . "\n",  
            esc_attr( 'link-' . $user->ID ),  
            esc_url( $user->image ),  
            esc_html( $user->name ),  
            esc_html( $user->ID )

but when i try to remove (%s) it just breaks the displayed result.

1

Try this but note that it may not send the message:

'<span id="%s" href="#"></span><img src="%s" style="width: 15px">   %s %s' . "\n",  
            esc_attr( 'link-' . $user->ID ),  
            esc_url( $user->image ),  
            esc_html( $user->name ),  
            ' '

Or this:

'<span id="%s" href="#"></span><img src="%s" style="width: 15px">   %s' . "\n",  
            esc_attr( 'link-' . $user->ID ),  
            esc_url( $user->image ),  
            esc_html( $user->name ) 
3
  • thank you @shanebp for the help. both ideas return error message that there is no valid username when i try to send. Even though it removes the username , when i click on displayed name i get html wrap text in the ''send'' field <span id="link-user" href="#"></span><img src="test.com/wp-content/uploads/avatars/35/user-bpthumb.jpg" style="width: 15px"> User May 11 '20 at 19:32
  • why i can not just do '<span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s <span id="remove">(%s)</span>' ? so i cound add a span and then hide with css May 11 '20 at 19:34
  • Did you try the 'remove' approach? I have no further suggestions.
    – shanebp
    May 11 '20 at 19:45
0

So i managed to solve this problem with some CSS, unfortunately there is no possibility to wrap with any html element around (%s) , BUT there is possibility to wrap with html the rest. So i did this

printf( '<span id="keep"><span id="%s" href="#"></span><img src="%s" style="width: 15px"> &nbsp; %s</span> (%s)' . "\n",

with out removing nothing from the original code, just adding the span 'keep' and then with the classic css visibility:hidden; trick i managed to hide it simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.