• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Archives for str_replace

str_replace

Display an icon with email link in the User List

Chad Butler · Oct 24, 2023 ·

I chose the basic email icon that is in the WP dashicons, but there are a couple of dashicon alternatives. And certainly, you could modify this code snippet to use any type of image/icon, such as font awesome. I used the WP dashicons because they are already loaded.

Adding the icon itself (without the link) is nothing more than adding the following span tag to the user profile:

<span class="dashicons dashicons-email"></span>

Adding to the user list view can be done with the wpmem_ul_user_rows filter. There is a verbose example below.

add_filter( 'wpmem_ul_user_rows', function( $rows, $list_id ) {
    
    // User ID is a field in the $rows array, get it as $user_id.
    $user_id = $rows['ID'];
    
    // User email will be in the $rows array by its meta key (see WP-Members Fields tab).
    // HOWEVER, it will have a div wrapper, so we'll strip that out first. (I put them
    // in variables to reuse later when we rewrap the field before returnning).
    $user_email = $rows['user_email'];
    $wrapper_start = '<div class="user_email">';
    $wrapper_end = '</div>';
    $raw_email = str_replace( array( $wrapper_start, $wrapper_end ), array( '', '' ), $user_email );
    
    // Get the dashicon.
    $icon = '<span class="dashicons dashicons-email"></span>';
    
    // Linked icon with the email text.
    $email_w_icon = '<a href="mailto:' . $raw_email . '">' . $icon . '</a> ' . $raw_email;
    
    // Put the div tag back.
    $rows['user_email'] = $wrapper_start . $email_w_icon . $wrapper_end;

    // Return the filtered result.
    return $rows;
    
}, 10, 2 );

Generate Random Display Name Part 2

Chad Butler · Dec 12, 2015 ·

This tutorial is an extension of the tutorial Generate Random User Display Name and Nickname that describes a process to generate random display names for users. In this tutorial we will explore how to add a process to the User Profile page that would allow users to select a new randomly generated display name from a list of choices.

The concept here is that we don’t want users selecting their own display names so that they fit within a specific rule set.  Preventing the user from choosing their own display name that fits the rule set makes it easier to manage.

This is a good tutorial for anyone that wants to build more complex user dashboards, but to implement it you should familiarize yourself with the part 1 of the tutorial as this will only be extending that process.  Continue Reading →

Creating an optgroup tag in a dropdown list

Chad Butler · Apr 16, 2015 ·

Here is a slightly more advanced example of using the wpmem_register_form_rows filter to modify a form input element. In this case, we will take a regular dropdown select field and add the optgroup label tag to sections of it.

Note: for best results in understanding this customization, it is best to create a test field exactly as described in this example and using the example scripts as they are written.  Once you have it working, then you can move to creating this process for your specific field. Continue Reading →

Replace form label tags with input tag placeholders

Chad Butler · Feb 24, 2015 ·

For those that are looking to shape the forms into a specific design that may include using input tag placeholders rather than labels, this set of code snippets will describe how to do that.  Continue Reading →

Customizing form CSS: Login widget with inline inputs

Chad Butler · Jan 13, 2015 ·

This post is an example of manipulating the WP-Members login widget to display inline (inputs on a single line).

Since the involves some HTML changes and some specific CSS, please consider this an example.  You will get your best results if you first try to reproduce the example as given.  While you might get part way there just dropping the example into your own site, if you are running 20 different plugins and a highly customized theme, you probably won’t get the same results out of the gate.  This example is not intended to be a one-size-fits-all solution because with the amount of variable pieces, that’s not realistic.  It is intended to be an example of specific filter hooks available in the plugin for you to be able to learn how customize the HTML output to fit your specific need.

Here is an image of what we will create with this example:

3 Continue Reading →

  • Page 1
  • Page 2
  • Page 3
  • Interim pages omitted …
  • Page 7
  • Go to Next Page »

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy