authentication - Wordpress to generate WP_Error Object for user login? -
i want return login error message user key-in privileges correctly. in other words, terminate login , show error message.
when key-in wrong passwords, wordpress shows:
there error authenticating details. error: password entered username admin incorrect. lost password?
.. on login page. because of wp_error
object returned.
so curious question is:
- how get/generate
wp_error
object on own, return back? array?
you need hook authenticate wordpress hook. return new wp_error object generate error message , redirect login page. here example.
add_filter('authenticate', 'check_login_submit', 40, 3); function check_login_submit($user, $username, $password) { $wp_error = new wp_error(); $wp_error->add('my_error', '<strong>error</strong>: went wrong.'); return $wp_error; }
Comments
Post a Comment