Remove Username Character Limit from WordPress Multi-Site / Multi-User

May 13th, 2010  |  Published in technology

I’ve been working on a pretty complex project with WordPress MultiUser (soon to be MultiSite). This client needs several sites with hundreds of users divided into each site. I will be integrating the backend authentication with LDAP and discovered that a small percentage of their users have usernames with fewer than four characters.

WordPress MU currently has a minimum limit of four characters set in its core. Unfortunately, this limit is still imposed in WordPress MS 3.0. The limit is probably there because usernames were used for the domain too and WP-Devs didn’t want to conflict with country codes. But that is not an issue for my client, so I wanted to kill the limit (without touching core).

Basically, I wrote a quick mu-plugin that unset the error message when someone tries to add a user with fewer than four characters. Doing this removes any halts that would stop processing the new user. Here is my code:

function remove_username_char_limit($result) {
  if ( is_wp_error( $result[ 'errors' ] ) && !empty( $result[ 'errors' ]->errors ) ) {

    // Get all the error messages from $result
    $messages = $result['errors']->get_error_messages();
    $i = 0;
    foreach ( $messages as $message ) {

      // Check if any message is the char limit message
      if ( 0 == strcasecmp("Username must be at least 4 characters", $message)) {
        // Unset whole 'user_name' error array if only 1 message exists
        // and that message is the char limit error
        if ( 1 == count($messages) ) {
          unset( $result['errors']->errors['user_name'] );
        } else {
          // Otherwise just unset the char limit message
          unset( $result['errors']->errors['user_name'][$i] );
        }
      }	

      $i++;
    }
  }

  return $result;
}
add_action('wpmu_validate_user_signup', 'remove_username_char_limit');

Tags: , , , , , ,


Warning: Invalid argument supplied for foreach() in /homepages/3/d238924033/htdocs/lewayotte.com/wp-content/plugins/yet-another-related-posts-plugin/magic.php on line 54

Easily Extended Contact Info in WordPress

April 22nd, 2010  |  Published in technology

I’m working on a project where I need the ability to add “Phone”, “Building”, and “Room” as information a user could add in their profile. I also wanted to remove “AIM”, “Yahoo”, and “Jabber” — none of the users are going to need to fill in that info.

You can easily add this code into your functions.php. I was writing it for a WordPress MU site with multiple themes and needed to make sure it was enforced, so I stuck it in the mu-plugins directory, in a file named “extended-contact-info.php”.

This is the simple code block you need:

function extended_contact_info($user_contactmethods) {
	//Use this if you want to append to the default
	//contact methods (AIM, Yahoo, Jabber)
	//$user_contactmethods += array(
	//	'building' => __('Building'),
	//	'room' => __('Room'),
	//	'phone' => __('Phone')
	//);

	//Use this if you want to ignore the default
	//contact methods (AIM, Yahoo, Jabber)
	$user_contactmethods = array(
		'building' => __('Building'),
		'room' => __('Room'),
		'phone' => __('Phone')
	);

	return $user_contactmethods;
}

add_filter('user_contactmethods', 'extended_contact_info');

Tags: , , , ,


Warning: Invalid argument supplied for foreach() in /homepages/3/d238924033/htdocs/lewayotte.com/wp-content/plugins/yet-another-related-posts-plugin/magic.php on line 54

Notable Tech Posts – 2010.03.07

March 7th, 2010  |  Published in technology

Not much this week…

25 excellent jQuery tutorials for navigation menu

http://www.iconfinder.net/free_icons

WordPress tip create a PDF viewer shortcode

30 jQuery tooltip plugins to enhance your web design

6 critical WordPress plugins you should have installed

WordPress theme development checklist

How to effectively write a tutorial

Tags: , , , , , , , ,


Warning: Invalid argument supplied for foreach() in /homepages/3/d238924033/htdocs/lewayotte.com/wp-content/plugins/yet-another-related-posts-plugin/magic.php on line 54

Notable Tech Posts – 2009.11.08 (a little late)

November 11th, 2009  |  Published in technology

The list of jQuery plugins

jQuery for web design navigation

Firequery Firebug enhancements for jQuery

5 must read presentations about CSS coding

Modern CSS layouts the essential characteristics

12 lesser known but useful WordPress hacks

10 awesome techniques and examples of animation with jQuery

Fresh PHP resources and tutorials

Beautiful Apple gallery slideshow

20 useful nicely designed web applications

How AJAX works: 10 practical uses for AJAX

13 really useful online CSS tools to streamline development

YouTube adaptable view CSS, jQuery

10 useful text enhancing plugins for WordPress

Exceptional PHP introduction to exceptions

Tags: , , , , , , , , ,


Warning: Invalid argument supplied for foreach() in /homepages/3/d238924033/htdocs/lewayotte.com/wp-content/plugins/yet-another-related-posts-plugin/magic.php on line 54