Here’s the full working code, put it in functions.php:
add_action('login_form','my_added_login_field');
function my_added_login_field(){
?>
<p>
<label for="my_extra_field">I agree to the terms<br />
<input type="checkbox" value="1" class="input" id="my_extra_field" name="my_extra_field_name"/></label>
</p>
<?php
}
function check_checkbox($user, $password)
{
if( !isset($_POST['my_extra_field_name']) )
{
remove_action('authenticate', 'wp_authenticate_username_password', 20);
$user = new WP_Error( 'denied', __("<strong>ERROR</strong>: Please agree to our terms.") );
}
return $user;
}
add_filter( 'wp_authenticate_user', 'check_checkbox', 10, 3 );
Related Posts:
- Can I programmatically login a user without a password?
- What is $interim_login?
- Adding extra authentication field in login page
- What exactly is ReAuth?
- Login members using web services
- Disable WordPress 3.6 idle logout / login modal window / session expiration
- How to pass users back and forth using session data?
- Need to execute a cron job
- how to update current logged user username
- Calling wp_signon doesn’t log the user in
- How to implement Google reCaptcha without installing a plugin?
- Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
- Are there ways of logging in that bypass wp-login.php altogether?
- How to display username and password after registration
- Two factor authentication
- How to generate “WP_Error” Object for user login?
- Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
- Where is the php file, that does the checks for login information?
- I want login using email not username wordpress front end
- Reloading page with a query string upon login for admins
- WordPress authentication using custom php?
- authenticate user without redirecting
- Multiple issues with Ajax login function due to browsers and cookies
- How to post frontend login form to a different authentication script from wp-login?
- Custom user roles are unable to login
- Using WordPress login for a non word-press website
- Extend Cookie with auth_cookie_expiration not working
- Can we start session from another php site to wordpress blog site?
- Opening protected page with cookie?
- Handle POST request sent from an external site for login?
- External Authentication
- Login and register by API
- Increase of failed login attempts, brute force attacks? [closed]
- How to prefill WordPress registration with social details
- How do I require authorization / login to view a specific set of posts / pages?
- Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
- wp_signon() does not authenticate user guidance needed
- WordPress auto login after registration not working
- Avoid to load default WP styles in login screen
- How to check WordPress website username and password is correct
- Programmatically log in a wordpress user
- Send reset password link to user from custom lost password form
- How long do users stay logged in if they DON’T check remember me?
- wp_authenticate but not logged in
- Remove WordPress Login Animation
- Redirect users to a front end wp login page
- Redirecting or displaying a message on first login
- Deny a user role to log in after register
- wp_get_referer not working properly after wp_redirect
- Login Button CSS
- Force Users to Login – loop problem
- Is there a better way than checking user is logged in to show or hide adminbar?
- How do I replace “Username” in the WordPress login form?
- Show errors on custom login form [duplicate]
- How to save generated JWT token to cookies on login?
- Change login_message using title
- Changing WP login credential [closed]
- How to change wordpress Log In text
- Can I (and should I) change the login-URL from functions.php?
- WordPress Cant access wp-login.php
- How to remove ‘wordpress…’ text from page titles in tabs
- Using gettext to translate wp-login.php can’t translate `Back to` into other language
- Display first name instead of username
- How can I make a login just like on wordpress.org?
- How to Prevent Brute Force Attack on WordPress
- How can I insert wordpress login screen on a different domain?
- autocomplete=”off” WordPress Login
- Why there is a 302 status when my account and password are right?
- 503 Login WordPress [closed]
- Password recovery URL has error – but not found in code or db
- This webpage has a redirect loop issue
- Create front end member login
- I can’t access my wp-admin dashboard
- Cannot login to WordPress on one device: login refreshes/an error was encountered whilst trying to authenticate
- Make an order of products without login
- Updated : how to make email optional while user registration using default wordpress form
- I can’t log in to `wp-admin` after changing my domain
- My wordpress site crashes when I login!
- End session screen not close automatically after login
- Unable to login with email address as the username – WordPress
- Bypass login page
- Using is_user_logged_in() to lock down whole site
- WordPress login is not showing , there is warning?
- WordPress Redirect After logging
- How to Create a login for for subscribers only
- WordPress auto login user after registration only from a specific page
- Custom Field For Login
- User login without username, only password
- Login user after registration programmatically
- wp_lostpassword_url not escaped
- Change All Login/Signup Links in Plugin
- Directory authentication initially succeeded, but no valid profile was found (“get entries” procedure)
- Login to wordpress with filezilla client [closed]
- I can’t login to wordpress dashboard without SSH
- Member Area Login with Fail Message
- Users cannot log in using popup
- issue with my wp site after login
- How can I automatically change directory on ssh login?
- How to create a fully functional user registration in WordPress?
- How to remove without touching the pluggable.php the wordpress_logged_in cookie to show the username on login?