• Resolved Coondron

    (@coondron)


    Hello there!

    Really impressed with the WP-Plugin and the documentation provided, the linked resource was perfect for me in regards to setting up a Unique ID with User Registration.

    The issue I am having is how to now tie that into the Login Form. The Unique ID is generating and emailing/displaying as per the instructions in the attached article, just hoping to now tie that into the Login as an added security layer.

    Again, very impressed with the look, feel and UI of the front & back-end of the plug-in.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • @coondron

    You can try this code snippet for verification of the User account ID at login.

    Create a new text field in your UM Login form and assign the meta_key um_unique_account_id_login to this field ie your Account ID meta_key from your Registration form with the added _login.

    If you have changed the Account ID meta_key in your Registration form’s code snippet update also the code line define( 'USER_ACCOUNT_ID', 'um_unique_account_id' ); in this code snippet.

    Install the code snippet into your active theme’s functions.php file
    or use the “Code Snippets” plugin.

    https://wordpress.org/plugins/code-snippets/

    add_filter( 'um_custom_authenticate_error_codes', 'um_account_id_error_code', 10, 1 );
    
    function um_account_id_error_code( $array ) {
    
        define( 'USER_ACCOUNT_ID', 'um_unique_account_id' );
    
        $array[] = USER_ACCOUNT_ID . '_login';
        return $array;
    }
    
    add_filter( 'wp_authenticate_user', 'authenticate_user_account_id', 999, 1 );
    
    function authenticate_user_account_id( $user ) {
    
        if ( ! is_wp_error( $user ) && isset( $_POST['form_id'] )) {
            $account_id_login = USER_ACCOUNT_ID . '_login-' . sanitize_text_field( $_POST['form_id'] );
            if ( isset( $_POST[$account_id_login] ) && ! empty( $_POST[$account_id_login] )) {
                um_fetch_user( $user->ID );
                if ( sanitize_text_field( $_POST[$account_id_login] ) != um_user( USER_ACCOUNT_ID )) {
                    return new WP_Error( USER_ACCOUNT_ID . '_login', __( 'Account id is incorrect. Please try again.', 'ultimate-member' ) );
                }
            } else {
                return new WP_Error( USER_ACCOUNT_ID . '_login', __( 'Please enter your account id.', 'ultimate-member' ) );
            }
        }
        return $user;
    }
    Thread Starter Coondron

    (@coondron)

    G’Day Missveronica,

    Thank you for taking the time to assist me with this, I do appreciate it.

    Works like magic, thank you ever so much!

    Thread Starter Coondron

    (@coondron)

    So one thing I was doing wrong that I managed to Identify.

    For some reason I thought the field with um_unique_account_id had to be on the registration form (confusing the tutorials section about ‘showing on profile’)

    So because the field was there on the registration form it wasn’t working, removing the field and it worked correctly again.

    • This reply was modified 6 months ago by Coondron.
    • This reply was modified 6 months ago by Coondron.
    • This reply was modified 6 months ago by Coondron.
    • This reply was modified 6 months ago by Coondron.
    • This reply was modified 6 months ago by Coondron.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @coondron

    Did you solve this problem? Can I close this topic?

    Regards.

    Thread Starter Coondron

    (@coondron)

    Yes, all sorted thanks. Missveronica was spot on the money 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.