Forums

Delete Row From WP Users...Simple Code Should Work...But It Isn't (3 posts)

  1. v_andreev
    Member
    Posted 1 year ago #

    Not really understanding why this doesn't work..I'm trying to look for duplicate user info in a DB and if it finds it, delete "one" of the rows (I'm having an issue where two rows are created)...

    function deleteDupUsers($user_login){
    
    global $wpdb;
    
    $username_rows = $wpdb->get_results( "SELECT FROM {$wpdb->users} WHERE user_login = %s", $user_login );
    
    $count=0;
    
    if (count($username_rows) > 1){
    
    	while($count < 1){
    
    		$wpdb->query("DELETE FROM {$wpdb->users} WHERE user_login = %s", $user_login );
    
    		$count++;
    	}
    
    }
    
    }

    This should do it...right?

  2. pgibbs
    Member
    Posted 1 year ago #

    Per the advice given on the BuddyPress forums, you really need to be figuring out why you're ending up with duplicated entries in wp_users first.

  3. v_andreev
    Member
    Posted 1 year ago #

    thanks for the reply...as advised, I'll probably just end up reloading the files...I posted this right before reloading the files was advised...

Topic Closed

This topic has been closed to new replies.

About this Topic