LLMS_Forms::are_usernames_enabled()

Determine if usernames are enabled on the site.


Description Description

This method is used to determine if a username can be used to login / reset a user’s password.

A reference to every form with a username block is stored in an option. The option is an array of integers, the WP_Post IDs of all the form posts containing a username block.

If the array is empty, there are no forms with username blocks and, therefore, usernames are disabled. If the array contains at least one item that means there is a form with a username block in it and, we therefore consider usernames to be enabled for the site.

This isn’t perfect. We’re well aware. But usernames are kind of silly anyway, right? Just use the email address like your average website owner and stop pretending usernames matter.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/forms/class-llms-forms.php

	public function are_usernames_enabled() {

		$locations = get_option( 'llms_forms_username_locations', array() );

		/**
		 * Use this to explicitly enable of disable username fields.
		 *
		 * Note that usage of this filter will not actually disable the llms/form-field-username block.
		 * It's possible to create a confusing user experience by explicitly disabling usernames and
		 * leaving username field blocks on one or more forms. If you decide to explicitly disable via
		 * this filter you should also remove all the username blocks from all of your forms.
		 *
		 * @since 5.0.0
		 *
		 * @param boolean $enabled Whether or not usernames are enabled.
		 */
		return apply_filters( 'llms_are_usernames_enabled', ! empty( $locations ) );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.