• I have been working on a custom plugin for my organization. The plugin basically provides a medium for users to register and login.

    I created a custom database table in the WordPress database to store information about registered users. However, when working the wp_authentication_username_password function, it failed to authenticate users whose information was stored in the custom table lablled wp-finusers. After researching I then realized that, the function was using the default users table to authenticate users.

    The reason I wanted to use a custom table was to separate registered users and the WordPress Administrative users.

    My question, is there a WordPress Filter that will enable the wp_authentication_username_password to using the custom table to perform user authentication or will I have to reconfigure the wp-core files to enable me to do so?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Thread Starter ggedare

    (@ggedare)

    @steve Stern, Sorry about not getting back to you. Was looking for a action/filter that could help me.

    Thanks

    I will let you if I can get it to work.

    thanks

    Thread Starter ggedare

    (@ggedare)

    @steve, this what I have done after reading the link you provided.

    add_filter('wp_authenticate_user', 'custom_authentication',10 ,2);
    	
    	function custom_authentication($emailAdd, $password) {
    		global $wpdb, $formErr;
    		
    		if(1 > count($formErr->get_error_messages())){
    			$table = $wpdb->prefix.'finusers';
    			$sql = "SELECT * FROM $table WHERE email_address='$emailAdd' AND password='$password'";
    			$authenticate_user = $wpdb->query($sql);
    			
    			if($authenticate_user!=0){
    				echo "Successful Authenticated user";
    			}else{
    				echo "Failed to authenticate user";
    			}
    		}
    	}

    I still can get the user authenticated using this code, but is this the correct way to this? Any suggestions on adjusting this code would really be of great help.

    Thanks
    Gedare Dorke(@ggedare)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘User authentication’ is closed to new replies.