NaszvadiG
4/17/2014 - 9:03 AM

Test.php

<?php

// Remember to set the class name equal to the folder and file name!
class Test {
	
	// If this function is not found, the script will exit with an error
	public function get_information() {
		return array(
			// Enter every name you want to call your plugin
			'name' => 'Very Cool Test Plugin',
			// The id of the plugin, this should not contain spaces or other special characters except of '_'
			'ID' => 'test_plugin',
			// Short description of what your plugin does
			'description' => 'This is the first plugin I wrote, and it does ... nothing',
			// Your name (doesnt matter which one - nickname or your real name)
			'author' => 'hice3000',
			// The version of your plugin, should be numeric
			'version' => 0.1
		);
	}
	
	public function register_hooks() {
		return array(
			// pairs of key-value-entries, the key is the name of the hook, and the value the method in this class
			// CodeIgniter should call when an event is fired. The method name can be anyone you like! I prefer
			// 'on_<hook_name>'.
			'user.change_name' => 'on_change_username'
		);
	}
	
	// This method is called when the event 'system.pre_controller' was fired. Be sure to define the first parameter!
	// You can change the parameters like you want, but if you do, you have to return them again.
	public function on_change_username($params) {
		// In my plugin I want to do something really useless! Lets uppercase the username and put an 'i' in front of it!
		$new_name = $params['username'];
		
		$new_name = ucfirst($new_name);
		$new_name = 'i'.$new_name;
		
		$params['username'] = $new_name;
		return $params;
	}
	
}

?>