php - WORDPRESS: I have just created an extra column with phpMyadmin on my wp_user row, I now need each user to update that column when logged in -


wordpress: have created column phpmyadmin on wp_user row (foo), need each user update column when logged in. have called value each user by:

            <?php          $wpdb->hide_errors(); auth_redirect_login(); nocache_headers();                     $current_user = wp_get_current_user();                     if ( 0 == $current_user->id ) {                         // not logged in.                     } else {                         echo '<input>' . $current_user->foo . '/>';                       }                     ?> 

can please explain why did alter wordpress table ?

it such bad practice. highly doubt column persist if wp has update somewhere in time.

there table called wp_usermeta fits needs.

you can access , update value with:

update_usermeta($userid,'foo',"1");

$foo = get_usermeta($userid,'foo');

now, main issue, can overload wp_authenticate function or, use filter "authenticate" (taken mjangda's answer).

add_filter('authenticate', 'check_login', 10, 3); function check_login($user, $username, $password) { $user = get_userdatabylogin($username);   if( /* check see if user allowed */ ) {     return null; } return $user; 

}


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -