Extension talk:CustomUserCreateForm

Latest comment: 12 years ago by Fladei in topic How to add a custom field

In MediaWiki 11.1.0, error as follows:

Fatal error: Cannot redeclare class UserloginTemplate in

/home/memswiki/public_html/extensions/customUserCreateForm/templates/customUserlogin.php on line 94

On customUserlogin.php needs to rename UserLoginTemplate class to customUserLoginTemplate

Note

edit

The UsercreateTemplate and UserloginTemplate classes have been split into separate files. Be sure to be careful with that.Jasper Deng (talk) 05:40, 26 February 2012 (UTC)Reply

How to add a custom field

edit

First of all, this was made by using Mediawiki 1.17.0 and customUserCreateForm version 0.1
Said so, let's start

Add the field to the registration form

edit

File Old: templates/customUserLogin.php
File New: templates/customUsercreate.php
Process:

  • Add the following line somewhere in the middle of the execute method of the customUsercreateTemplate class.
$this->addInputItem('fieldname', 'default value', 'input type', 'Left column message');

Managing the data retrieved by the new fields and adding it to the database

edit

File: templates/customUserCreateForm.php
Process:

  • Add a new AddNewAccount hook at the top of the file:
  • Create a new function that will handle the data with the same name as stated on the AddNewAccount hook registration. All the data from the registration process can be retrieved via wgRequest global variable
  • Store the data in the user_properties table by using wfGetDB (DB_MASTER)

Example:

$wgHooks['AddNewAccount'][] = 'customUserSaveToDB';

function customUserSaveToDB( $user, $byEmail){
	global $wgRequest;
	$dbw = wfGetDB( DB_MASTER );
	$dbw->insert( 'user_properties', array(
		'up_user'     => $user->getID(),
		'up_property' => 'city',
		'up_value'    =>  $wgRequest->getText( 'wpCity' )
	));
	return true;
}

Add new data to Special:Preferences page

edit

File: templates/customUserCreateForm.php
Process:

  • Add a new GetPreferences hook at the top of the file:
  • Create a new function that will handle the custom user preferences section with the same name as stated on the GetPreferences hook registration.
  • Call the data in the user_properties table by using the preferences variable

Example:

$wgHooks['GetPreferences'][] = 'customUserPreferences';

function customUserPreferences ($user, &$preferences)
{
    $preferences['city'] = array(
    	'type' => 'text',
        'label-message' => 'customUserCity', // a system message
        'section' => 'personal/info',
	);

	// Required return value of a hook function.
    return true;
}


Create the custom system messages for the new fields

edit
  • For each new property in the preferences, visit the MediaWiki:systemMessageForTheProperty article of your wiki and edit it by adding the name of the field you wish to appear next to the preferences box field.

Get data from the database

edit

The SQL query for getting the data from the database should go as following:

SELECT user_name, user_email, up_user, up_property, CONVERT(up_value USING utf8) AS yourFieldName FROM user_properties
JOIN user ON user.user_id=user_properties.up_user
WHERE up_property IN ('field1','field2',...) AND (up_value IS NOT NULL AND (TRIM(up_value) != ''))
ORDER BY user_name DESC

That should be all! Enjoy your new customized registration tool
--Fladei (talk) 20:01, 15 April 2012 (UTC)Reply

If you wish to inject text into the UI this DOES NOT WORK. FIX IS INCLUDED

edit

The function prototype needs to be:

function customUserCreateForm(&$template) {

NOT

 
function customUserCreateForm($template) {

$template needs to be passed by reference because the execute() function that renders the content is call after the hooks are exected.


-Michael Lapinski -mtl[attt]mit[dot]edu

Extension NOT clear

edit

Can you please provide more about how does this extension work and how to create new columns in database if i want to add birth date and country ' ANY ADVICE PLEASE

Is this extension still supported

edit

Is this extension still supported please let us know

custom user create form dont work in 1.27 version

edit

Hi every one.

Yesterday ,I was upgrade my system from 1.24 to 1.27 ,but the (customUserCreateForm) extension dont work any more.


The new version does not read my custom template , as it is not exist .

Does there is a new way to build a custom create and login form in a new version?

Please help.

Thank you.

In a last version of mediawiki(1.27) on the (realease-note) file , there is a following line:

      • AbortNewAccount (create a MediaWiki\Auth\PreAuthenticationProvider instead)

What the mean of (create a MediaWiki\Auth\PreAuthenticationProvider instead)?? This sentence was written multiple times , especially near the hooks that no more working in a new version (1.27)

create a MediaWiki\Auth\PreAuthenticationProvider instead

edit

In a last version of mediawiki(1.27) on the (realease-note) file , there is a following line:

AbortNewAccount (create a MediaWiki\Auth\PreAuthenticationProvider instead) What the mean of (create a MediaWiki\Auth\PreAuthenticationProvider instead)?? This sentence was written multiple times , especially near the hooks that no more working in a new version (1.27)

Return to "CustomUserCreateForm" page.