ClassesBigCommerceAccountsLogin

Login

Handles the login and lost password logic for the BigCommerce account integration with WordPress.

This class connects WordPress users to BigCommerce customers, processes customer login, and provides the necessary functionality for user management.

  • Full name: \BigCommerce\Accounts\Login

Constants

ConstantVisibilityTypeValue
CUSTOMER_ID_METApublic’bigcommerce_customer_id’

Methods

__construct

Login constructor.

public __construct(\BigCommerce\Api_Factory $api_factory): mixed

Parameters:

ParameterTypeDescription
$api_factory\BigCommerce\Api_FactoryThe API factory to be used for creating API instances.

connect_customer_id

Connect the user to a BigCommerce account, if it exists

public connect_customer_id(string $username, \WP_User $user): void

Parameters:

ParameterTypeDescription
$usernamestring
$user\WP_User

login_url

Filters the login URL to point to the front-end login page

public login_url(string $login_url, string $redirect, bool $force_reauth): string

Parameters:

ParameterTypeDescription
$login_urlstringThe login URL. Not HTML-encoded.
$redirectstringThe path to redirect to on login, if supplied.
$force_reauthboolWhether to force reauthorization, even if a cookie is present.

login_error_handler

Handle errors from the login form, redirecting back to the front-end login page.

public login_error_handler(\WP_Error $errors, string $redirect): \WP_Error

Note that is hooked in on a filter, not an action, since the latter was not available.

Parameters:

ParameterTypeDescription
$errors\WP_Error
$redirectstring

lostpassword_url

Get lost password url

public lostpassword_url(string $login_url, string $redirect): string

Parameters:

ParameterTypeDescription
$login_urlstring
$redirectstring

before_reset_password_email

If a user exists only on BC, try to sync before reset password email is sent.

public before_reset_password_email(\WP_User|false $user_data, \WP_Error $errors): \WP_User|false

Parameters:

ParameterTypeDescription
$user_data\WP_User|falseWP_User object if found, false if the user does not exist.
$errors\WP_ErrorA WP_Error object containing any errors generated
by using invalid credentials.

lostpassword_error_handler

public lostpassword_error_handler(\WP_Error $error): void

Parameters:

ParameterTypeDescription
$error\WP_Error

register_url

Handle registration url

public register_url(string $url): string

Parameters:

ParameterTypeDescription
$urlstring

redirect_account_pages_to_auth

Redirect all account pages to the login screen for unauthenticated users.

public redirect_account_pages_to_auth(): void

redirect_auth_pages_to_account

Redirect the login/registration pages to the account page for logged in users.

public redirect_auth_pages_to_account(): void

authenticate_new_user

If a user logs in with credentials for a user in BigCommerce that do not match a user in WordPress, create a user account and log the user in.

public authenticate_new_user(\WP_User|\WP_Error|null $user, string $username, string $password): \WP_User|\WP_Error|null

Parameters:

ParameterTypeDescription
$user\WP_User|\WP_Error|null
$usernamestring
$passwordstring

check_password_for_linked_accounts

Validate password for accounts

public check_password_for_linked_accounts(bool $match, string $password, string $hash, string|int $user_id): bool

Parameters:

ParameterTypeDescription
$matchboolWhether the passwords match.
$passwordstringThe plaintext password.
$hashstringThe hashed password.
$user_idstring|intUser ID. Can be empty.


Automatically generated on 2025-01-21