LoginWithAJAX::output( array $args )

Outputs the login form directly to the browser. Ultimately, shortcodes, blocks and other display methods will call this function to output the login form.


Description

You can display a login form via PHP pretty much the same way as you would with the shortcode [lwa]:


	LoginWithAJAX::output(
		array(
			'template' => 'minimalistic',
			'redirection' => 'https://some-special-redirect.com',
			'profile_link' => false,
		)
	);
	

For more information about the possible configurations in a login form, please visit the login form documentation page as these configurations apply to all methods of displaying the login form. This page will inform you of the right argument names specifically for shortcodes.


Return

This function outputs the login form directly to the browser, use LoginWithAJAX::get_output( $args ); to get the string content instead of outputting it to the browser.


Parameters

$args (array) is an optional associative array. Below you'll see all the available arguments with their default values.

General Arguments

These are general arguments that apply to whether the user is logged in our out.

Argument Default Description
template

(string)

settings default

The template to be used, which would override the default template choice.

Note The value used here would be the registered name of the template (usually uncapitialized with hyphens for spaces), not the label name. The default templates are:

default - Default
minimalistic - Minimalistic
modal - Modal
modal-minimalistic - Modal Minimalistic
template_color

(string)

settings default

Color base to use for links, buttons etc. in templates. Accepts a hex or hsl CSS format value, such as #123abc or 10,100%,50% (do not wrap hsl values in hsl())

Note Custom templates may not support this feature.

css_style

(string)

none

Add inline CSS rules to the outer .lwa class located in your template files. This can include any CSS rules such as margin:10px; or our custom CSS variables such as --background-color:#FFFFFF;

Important Ensure you add a semicolon to the end. This inline CSS you add here is added to the start of the style="...", further rules maybe added dynamically during output.

css_vars

(array)

none

Add custom CSS variables to the outer .lwa class div wrapper and change specific styling options for this form. Accepts an array of CSS variable names as keys and corresponding values, keys without the preceding --, for example:

$args['css_vars'] = array(
		'template-color' => '#fff',
		'varname' => 'value',
	);

Would translate to the following CSS inline rule --template-color:#fff; --varname:value;.

Important This inline CSS you add here is added to the end of the style="..." attribute, after css_style rules.

vanilla

(boolean)

false

If set to false, LWA's CSS templating is not applied to this form, making it 'vanilla' and adapts to the CSS styling of your theme.

Note Due to every theme having their own unique stying, there may be unexpected results/consistency. Custom templates may not support this feature.

Login Arguments

These are arguments that apply to when a user is logged out and viewing the login form.

Argument Default Description
title

(string)

none Title text to add above the login form. HTML not admitted and will be escaped to be displayed literally.
registration

(int)

1

Whether or not to display the Registration link. Accepts the following values:

0 - Do not show
1 - Show link with AJAX form
2 - Link directly to original form
remember

(int)

1

Whether or not to display the password recovery link. Accepts the following values:

0 - Do not show
1 - Show link with AJAX form
2 - Link directly to original form
rememberme

(int)

1

Whether or not to display the Registration link. Accepts the following values:

0 - Do not show
1 - Show, unchecked by default
2 - Show, checked by default
3 - Hide but enabled/checked
redirect

(string)

none Where to redirect upon successful login. Accepts a full url, e.g. https://someplace.com If not set, the default redirection options will be used.
refresh

(bool)

true

If true, refresh the page upon a successful login.

If set to 0, the login form (or modal button) will be replaced with a logged in widget instead.

This value will supercede the redirect option and will prevent redirection if refreshing is disabled.

Logged In Arguments

These are arguments that apply to when a user is logged in and viewing their profile widget.

Argument Default Description
title_loggedin

(string)

none

Title text to add above the user details widget when logged in. HTML not admitted and will be escaped to be displayed literally. The following placeholders can be used to replace wyt dynamic info:

%USERNAME% - Do not show
profile_link

(bool)

true

If true, display a link to the user profile page.

loggedin_vertical

(bool)

false

If true, show a vertical style, where avatar apears on top, links below.

avatar_size

(int)

60

The size of the avatar to be displayed, in pixels. Do not include the px, just use a number.

avatar_rounded

(bool)

false

If true, the avatar will be displayed as a circular picture rather than a square..

redirect_logout

(string)

none Where to redirect upon successful logout. Accepts a full url, e.g. https://someplace.com If not set, the default redirection options will be used.