Users Widget – Remove link when listing users
-
Hi again everyone,
I’m sorry I’m back again with another little problem with some of the functionality we’ve developed using your widget.
We LOVE the plugin and I have fallen in love with the fact we can generate a member list based on a specific role. It works perfectly – aside from the fact it tries to link “somewhere” to what I assume is a user profile.
I’m hoping to get a workaround – so I can JUST display the list of names – no other information and no link or click through.
Is anyone able to assist me with this?
I just want to take this opportunity to thank the plugin developer and all the forum members that have helped so far – I really appreciate the patience and help.
Amanda @ Pac Fire
The page I need help with: [log in to see the link]
-
Hi Amanda,
I apologize for the delay in response.
Thank you for your kind words. We appreciate it.
Users widget doesn’t have an option to disable links, but you could add this code at the end of your theme’s functions.php file:
add_shortcode( 'mb-display-users-list', function() { $users = get_users(); // If users were found. if ( ! empty( $users ) ) { echo '<ul class="xoxo users">'; // Loop through each available user, creating a list item. foreach ( $users as $user ) { $class = sanitize_html_class( "user-{$user->ID}" ); if ( is_author( $user->ID ) ) $class .= ' current-user'; printf( '<li class="%s">%s', esc_attr( $class ), esc_html( $user->display_name ) ); } echo '</ul>'; } } );
and then use the Shortcode widget to add this shortcode: [mb-display-users-list]. Here is the screenshot for reference: https://share.cspf.co/WnuyeA25
Hopefully, that helps.
Hi @caseproof
Thank you so much for your reply.
I copied that script into functions PHP and reloaded the page – at which point I got a critical error – this is before I tried to put the shortcode in.
I’m going to be 100% with you – I am not very good with PHP so I have no doubt that it’s something that I’ve done.
I have screenshots if you would like to have a look at the situation? I’m so sorry – I apologise for the questions and problems.
Amanda – Pac Fire
Hi Amanda,
I’m sorry to hear that you have experienced a fatal error. I’m sure that this code I’ve sent you was correct. Instead of inserting the code into theme’s functions.php file you can use this plugin: https://wordpress.org/plugins/code-snippets/ that allows you to keep code separated and activate/deactivate it any time.
You can also send me the screenshot of your code if you want.Kind regards
You can also send me the screenshot of your code if you want.
If anyone wants to post screenshots then I recommend this site.
Upload the image there and post the link to that image n reply here.
- The topic ‘Users Widget – Remove link when listing users’ is closed to new replies.