PHP code example of amostajo / wordpress-login-page

1. Go to this page and download the library: Download amostajo/wordpress-login-page library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amostajo / wordpress-login-page example snippets


    'Amostajo\Wordpress\LoginPageAddon\LoginPage',

add_filter( 'addon_loginpage_redirect_to', 'filter_redirect' );

function filter_redirect($redirect)
{
    // Modification
    $redirect = home_url( '/my-account.php' );

    // Array is expected in return
    return $redirect;
}

add_filter( 'addon_loginpage_signup_userdata', 'filter_signup_userdata' );

function filter_signup_userdata($userdata)
{
    // Add additional fields
    $userdata[ 'user_nicename' ] = Request::input( 'user_nicename' );
    $userdata[ 'address' ] = Request::input( 'address' );

    // Array is expected in return
    return $userdata;
}

add_filter( 'registration_errors', 'filter_signup_errors' );

function filter_signup_errors($errors, $user_login, $user_email)
{
    // Adding custom validations
    if ( strlen( Request::input( 'user_pass' ) ) >= 8 ) {
        $errors->add(
            'password_length',
            'Field <strong>Password</strong> should contain at least 8 characters.'
        );
    }
    if ( !Request::input( 'address' ) ) {
        $errors->add(
            'empty_address',
            'Field <strong>Address</strong> can not be empty.'
        );
    }

    // WP_Error
    return $errors;
}

add_filter( 'addon_loginpage_signup_message', 'filter_signup_message' );

function filter_signup_message($message)
{
    return 'Thanks for registering with us!';
}

add_filter( 'retrieve_password_title', 'filter_reset_email_title' );

function filter_reset_email_title($title)
{
    return 'Forgot your password?';
}

add_filter( 'retrieve_password_message', 'filter_reset_email_message' );

function filter_reset_email_message($message)
{
    return 'Reset password message';
}

add_filter( 'registration_errors', 'filter_resetpassword_errors' );

function filter_resetpassword_errors($errors, $input, $user)
{
    // Adding custom validation
    if ( strlen( $input[ 'user_pass' ] ) >= 8 ) {
        $errors->add(
            'password_length',
            'Field <strong>Password</strong> should contain at least 8 characters.'
        );
    }

    // WP_Error
    return $errors;
}

add_filter( 'addon_loginpage_forgotpassword_message', 'filter_forgotpassword_message' );

function filter_forgotpassword_message($message)
{
    return 'Reset instructions sent to your inbox.';
}

add_filter( 'addon_loginpage_resetpassword_message', 'filter_resetpassword_message' );

function filter_resetpassword_message($message)
{
    return 'Password changed!';
}

[addon-folder]
    /assets
        /views
            /addons
                /loginpage
                    /emails
                        resetpassword.php
                    login.php
                    lostpassword.php
                    resetpassword.php
                    signup.php

[theme-folder]
    /assets
        /views
            /addons
                /loginpage
                    /emails
                        resetpassword.php
                    login.php
                    lostpassword.php
                    resetpassword.php
                    signup.php