Jump to content

Change "Name" field label for users to "Username"


Soma
 Share

Recommended Posts

Some time ago there was a question if it's possible to change the "name" field on the users to "Username".

Here's how I answered with a module example. May it be helpful to someone.

<?php

class UserNameLabel extends WireData implements Module{

public static function getModuleInfo() {
	return array(
		'title' => __('UserNameLabel', __FILE__), // Module Title
		'version' => 100,
		'summary' => __('Overwrite User Name Label', __FILE__), // Module Summary
		'autoload' => true
		);
}

public function init() {
	// only add hook if on user pages
	if(strpos($_SERVER['REQUEST_URI'],'/users/') !== FALSE )
		$this->addHookAfter("Inputfield::render", $this, "changeLabel");
}

public function changeLabel($event){
	$inputfield = $event->object;
	// only if the right inputfield
	if(!$inputfield instanceof InputfieldName ) return;
	// overwrite the label
	return $event->object = $inputfield->label = __("Username");
}

}

UserNameLabel.module.zip

  • Like 2
Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...