Support » Plugin: Ultimate Member – User Profile, User Registration, Login & Membership Plugin » HOWTO – How to make a checkbox on the login form required

  • Resolved apiosys

    (@apiosys)


    Rather than using the official Terms & Conditions plugin, which only works on the registration form out of the box, I would like a user to tick a checkbox when logging in (yes, everytime). I thought I could simply inspire myself from this answer posted by the official support : https://wordpress.org/support/topic/i-agree-to-the-terms-privacy-policy-checkbox/ but I can’t get the custom checkbox to be obligatorily checked. Anyone an idea on this or experience with it?

    Kind regards,

    Joris.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter apiosys

    (@apiosys)

    Any ideas someone?

    Thread Starter apiosys

    (@apiosys)

    Self-reply: for those interested, I have accomplished this in a function in my theme so as not to modify the code of the plugin. In this exemple, the field created in UM forms is called agree_tc, ajust to your own needs as well as appropriate error message to user:

    // As part of UM authentication process, call function to verify TC checkbox
    add_filter('wp_authenticate_user', 'wp_authenticate_user_acc', 99999, 2);
    
    function wp_authenticate_user_acc($user, $password) {
        // See if the checkbox #agree_tc was checked
        if ( isset($_POST['agree_tc']) ) {
            // Checkbox on, allow login
            return $user;
        } else {
            // Did NOT check the box, do not allow login
            $error = new WP_Error();
            $error->add('did_not_accept', 'Please confirm that you have read and accept the terms and conditions' );
            return $error;
        }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘HOWTO – How to make a checkbox on the login form required’ is closed to new replies.