Skip to main content
You are here:
Print

Hooks

These hooks can be used to add your custom logic after user logged in or linked an account using the EthPress plugin functionality.

Free hooks

The login_redirect hook is a standard WordPress hook you can use to customize the page user should be redirected after login.

The EthPress PRO version has a feature to configure it on the plugin settings page. Free 7 days Trial is available!

/**
 * Fires after every login attempt.
 *
 * @param WP_User|WP_Error $user WP_User on success, WP_Error on failure.
 * @param (string|false) $provider One of 'metamask', 'reown', false.
 */
do_action( 'ethpress_login', $user, $provider );

/**
 * Fires after every user account linking success.
 *
 * @param WP_User|WP_Error $user WP_User on success, WP_Error on failure.
 * @param (string|false) $provider One of 'metamask', 'reown', false.
 */
do_action( 'ethpress_linked', $user, $provider );

/**
 * Filters the login redirect URL.
 *
 * @param string           $redirect_to           The redirect destination URL.
 * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
 * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
 */
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );

/**
 * For additional checks in addons
 *
 * @since 1.6.0
 *
 * @param \losnappas\Ethpress\Address $address.
 * @return \losnappas\Ethpress\Address|\WP_Error Return \WP_Error if address doesn't fulfill some condition.
 */
$address = apply_filters('ethpress_login_address', $address);

/**
 * For additional checks in addons
 *
 * @since 1.6.0
 *
 * @param string           $redirect_to           The redirect destination URL.
 * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
 * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
 */
$redirect_to = apply_filters('ethpress_login_redirect', $redirect_to, $requested_redirect_to, $user);

/**
 * Filters the message a user signs in the wallet on login.
 *
 * The message needs to be the same when it is signed and when it is verified.
 * The nonce will be added on a new line after the filter runs.
 *
 * @since 0.1.0
 * @since 0.7.0 Has the wallet address as the 2nd argument: $coinbase.
 *
 * @param string $message  Message.
 * @param string $coinbase User's address.
 */
$message = apply_filters('ethpress_login_message', $message, $coinbase);

/**
 * Filters the email address used when registering a new wallet user.
 *
 * Return an empty string to fall back to the placeholder email derived from
 * the wallet address.
 *
 * @since 3.0.0
 *
 * @param string $email    Email address, empty when none was collected.
 * @param string $coinbase The wallet address being registered.
 */
$email = apply_filters('ethpress_register_user_email', $email, $coinbase);

/**
 * Filters the display name used when registering a new wallet user.
 *
 * The name is split into a first and a last name on the first space.
 *
 * @since 3.0.0
 *
 * @param string $name     Display name, empty when none was collected.
 * @param string $coinbase The wallet address being registered.
 */
$name = apply_filters('ethpress_register_user_name', $name, $coinbase);

/**
 * Filters the message shown when a wallet has no account on a site that does
 * not accept new registrations.
 *
 * The visitor reads this one, so it names the cause and what to ask the site
 * administrator for. The `Diagnostics` section of the settings page reports the
 * same setting.
 *
 * @since 3.0.0
 *
 * @param string $message  The message.
 * @param string $coinbase Wallet address, when known.
 */
$message = apply_filters('ethpress_registration_closed_message', $message, $coinbase);

/**
 * Filters the message shown when a wallet has no account while registrations are open.
 *
 * @since 3.0.0
 *
 * @param string $message  The message.
 * @param string $coinbase Wallet address, when known.
 */
$message = apply_filters('ethpress_unregistered_message', $message, $coinbase);

/**
 * Filters whether the wallet login and register buttons are hidden on the WordPress login page.
 *
 * When true, the buttons are not printed on wp-login.php. Buttons rendered
 * with the shortcodes or the widget are not affected.
 *
 * @since 3.0.0
 *
 * @param bool $hide Whether to hide the wallet buttons on wp-login.php.
 */
$hide = apply_filters('ethpress_hide_on_wp_login', $hide);

/**
 * Filters the Terms & Conditions checkbox label shown next to the wallet login button.
 *
 * An empty string disables the checkbox even when the setting is set.
 *
 * @since 3.0.0
 *
 * @param string $text Checkbox label.
 * @param string $url  Terms & Conditions URL, or ''.
 */
$text = apply_filters('ethpress_terms_text', $text, $url);

/**
 * Filters whether the Terms & Conditions checkbox is required to log in.
 *
 * @since 3.0.0
 *
 * @param bool   $required Whether the checkbox must be ticked.
 * @param string $text     Checkbox label.
 * @param string $url      Terms & Conditions URL, or ''.
 */
$required = apply_filters('ethpress_terms_required', $required, $text, $url);

/**
 * Filters how long an issued login nonce stays valid.
 *
 * The nonce is issued when the wallet asks for the login message and consumed
 * when the signature is verified, so it is only useful once. This controls how
 * much time the user has to sign the message before it expires.
 *
 * @since 3.0.0
 *
 * @param int $lifetime Lifetime in seconds. Default 15 minutes.
 */
$lifetime = apply_filters('ethpress_nonce_lifetime', $lifetime);

/**
 * Filters the checks shown in the `Diagnostics` section of the plugin settings.
 *
 * Each check is an array with the `id`, `label`, `status` (`ok`, `warning` or
 * `error`), `value` and `help` keys.
 *
 * @since 3.0.0
 *
 * @param array $checks Report rows.
 */
$checks = apply_filters('ethpress_diagnostics', $checks);

/**
 * Filters the "you are already logged in" hint of the `[ethpress_login_button]`
 * shortcode.
 *
 * The hint is printed instead of the button when the visitor is logged in. It is
 * shown to site owners by default; the `notice="1"` shortcode attribute forces
 * it for everyone, `notice="0"` suppresses it.
 *
 * @since 3.0.0
 *
 * @param bool         $show Whether the hint is printed.
 * @param array|string $args Shortcode attributes.
 */
$show = apply_filters('ethpress_logged_in_notice', $show, $args);

/**
 * Filters whether the login signature is recovered by PHP instead of by the
 * verification service.
 *
 * Return false to send every signature to the configured service (for example
 * to keep the load off your web server); return true to keep the checks local.
 *
 * @since 3.0.0
 *
 * @param bool $ecrecovers_with_php Whether php-gmp or php-bcmath is loaded.
 */
$ecrecovers_with_php = apply_filters('ethpress_verify_signatures_with_php', $ecrecovers_with_php);

/**
 * Filters how long the signature self-test of the `Diagnostics` section waits
 * for the verification service.
 *
 * The self-test probes the service only when the service is the path the logins
 * take. Raise the timeout for a slow service (a login waits up to 45 seconds),
 * or lower it when the settings page must answer as fast as possible.
 *
 * @since 3.0.0
 *
 * @param float $timeout Timeout in seconds. Default 5.
 */
$timeout = apply_filters('ethpress_diagnostics_self_test_timeout', $timeout);

/**
 * Filters the text of the "you are already logged in" hint.
 *
 * @since 3.0.0
 *
 * @param string $text Hint text.
 */
$text = apply_filters('ethpress_logged_in_notice_text', $text);

PRO hooks

The EthPress PRO version is required to use these hooks. Free 7 days Trial is available!

In the Free version these filters are not applied.

/**
 * Filters whether a wallet login should "remember" the user.
 *
 * When true, a persistent auth cookie is issued, so the user stays logged in
 * across browser restarts instead of being logged out as soon as the session
 * cookie is discarded.
 *
 * @since 3.0.0
 *
 * @param bool    $remember Whether to remember the user.
 * @param WP_User $user     The user being logged in, when available.
 */
$remember = apply_filters('ethpress_login_remember', $remember, $user);

/**
 * Filters whether new wallet users are asked to complete their profile.
 *
 * When false, profile completion is disabled regardless of the configured
 * mode. When true, the mode decides how the email and name are collected:
 * inline with the login button, or by redirecting to the profile after the
 * first login.
 *
 * @since 3.0.0
 *
 * @param bool $enabled Whether to ask new wallet users to complete their profile.
 */
$enabled = apply_filters('ethpress_profile_completion', $enabled);

/**
 * Filters how new wallet users are asked to complete their profile.
 *
 * @since 3.0.0
 *
 * @param string $mode One of '', 'form' (inline form next to the login
 *                     button) or 'redirect' (redirect to the profile).
 */
$mode = apply_filters('ethpress_profile_completion_mode', $mode);

/**
 * Filters the custom CSS applied to the login buttons and the wallet modal.
 *
 * @since 3.0.0
 *
 * @param string $css Custom CSS.
 */
$css = apply_filters('ethpress_custom_css', $css);

/**
 * Fires after a wallet has been unlinked from a user account.
 *
 * @since 3.0.0
 *
 * @param \WP_User $current_user The user the address was unlinked from.
 */
do_action('ethpress_unlinked', $current_user);

/**
 * Filters the message a user signs in the wallet when linking an account.
 *
 * The message needs to be the same when it is signed and when it is verified.
 * The site URL and the nonce will be added on new lines after the filter runs.
 *
 * @since 3.0.0
 *
 * @param string $message  Message.
 * @param string $coinbase User's address.
 */
$message = apply_filters('ethpress_link_sign_message', $message, $coinbase);

/**
 * Filters the success message shown after an account has been linked.
 *
 * @since 3.0.0
 *
 * @param string $message        The message.
 * @param string $short_coinbase Shortened wallet address.
 */
$message = apply_filters('ethpress_link_success_message', $message, $short_coinbase);

/**
 * Filters the success message shown after a wallet has been unlinked from a user account.
 *
 * @since 3.0.0
 *
 * @param string $message        The message.
 * @param string $short_coinbase Shortened wallet address.
 */
$message = apply_filters('ethpress_unlink_success_message', $message, $short_coinbase);

/**
 * Filters the login button label.
 *
 * @since 3.0.0
 *
 * @param string $label Button label.
 */
$label = apply_filters('ethpress_login_button_label', $label);

/**
 * Filters the link button label.
 *
 * @since 3.0.0
 *
 * @param string $label Button label.
 */
$label = apply_filters('ethpress_link_button_label', $label);

/**
 * Filters the unlink button label.
 *
 * @since 3.0.0
 *
 * @param string $label Button label.
 */
$label = apply_filters('ethpress_unlink_button_label', $label);

/**
 * Filters the register button label.
 *
 * @since 3.0.0
 *
 * @param string $label Button label.
 */
$label = apply_filters('ethpress_register_button_label', $label);
Categories: