Jump to content

Developer Documentation

Login Handler Settings

You will probably need some settings for the administrator to fill in when they set up a Login Method for your Handler in the AdminCP.

Some settings are already provided. You do not need to do anything with them, as Invision Community will handle the values automatically:

  • A name for the login method (the default value will be that which is provided by the getTitle() method).
  • Whether AdminCP logins are enabled
  • Whether new accounts are allowed
  • If you are using a Username/Password handler: whether the user will provide a username or an email address to log in. If you override the acpForm() method, you will need to add this back in unless you have hardcoded a value for authType().
  • If you are using an OAuth-based handler: settings for client ID, secret, and settings related to profile syncing.

There are three methods involved:

  • acpForm() returns an array of form elements controlling what is displayed in the form. You can also return strings which will create headers. You will override this adding your own elements.
  • acpFormSave() performs any modification of the values you want to do before saving. If not provided, the values will be saved automatically.
  • testSettings() tests that the settings are valid. It should return TRUE or throw a LogicException if the values are not valid.

You can then access the values of these settings in your login handler code through $this->settings.

Here is some sample code which you could add to the sample code provided in Creating a Button Handler which would allow the administrator to change the colour of the button:

	 * ACP Settings Form
	 * @param	string	$url	URL to redirect user to after successful submission
	 * @return	array	List of settings to save - settings will be stored to core_login_methods.login_settings DB field
	 * @code
	 	return array( 'savekey'	=> new \IPS\Helpers\Form\[Type]( ... ), ... );
	 * @endcode
	public function acpForm()
		return array(
			'my_login_handler_customization', // NOTE: Create a language string for this
			'button_color' => new \IPS\Helpers\Form\Color( 'my_login_handler_button_color', $this->buttonColor() ) // NOTE: Create a language string for this
	 * Get the button color
	 * @return	string
	public function buttonColor()
		return isset( $this->settings['button_color'] ) ? $this->settings['button_color'] : '#ff3399';


Edited by Mark

  Report Document

  • Create New...