{"id":1407,"date":"2023-10-31T11:46:06","date_gmt":"2023-10-31T11:46:06","guid":{"rendered":"https:\/\/mklasen.com\/?p=1407"},"modified":"2023-11-15T11:54:16","modified_gmt":"2023-11-15T11:54:16","slug":"deleting-a-pending-user-from-wordpress-using-wp-cli","status":"publish","type":"post","link":"https:\/\/mklasen.com\/deleting-a-pending-user-from-wordpress-using-wp-cli\/","title":{"rendered":"Delete a pending user from WordPress"},"content":{"rendered":"\n
It’s definitely not the first time that I ran into this situation; A user was added to the website without checking the “Skip confirmation email” checkbox. Now, we’d like to force this user into the website and just send a login and password over, but now we get the message:<\/p>\n\n\n\n
\n
That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.<\/code><\/p>\n<\/blockquote>\n\n\n\n
We don’t have a couple of days to wait, and we don’t want to use another e-mail address either. So what do we do?<\/p>\n\n\n\n
Note: This is a developer oriented approach for deleting pending users. If you’re not comfortable with WP-CLI or database changes, have a look at the Uncomfirmed p<\/a><\/em>lugin<\/a>.<\/strong><\/p>\n\n\n\n
Let’s go with WP-CLI<\/h1>\n\n\n\n
Let’s dive into the database<\/h2>\n\n\n\n
But honestly – I’d rather leave the database untouched. I rarely<\/em> touch WordPress databases and prefer to do any interaction with the database via code and terminal. <\/p>\n\n\n\n
So let’s use WP CLI as a wrapper instead!<\/h2>\n\n\n\n
So, first off – where are these pending activations stored? They’re in the
wp_signups<\/code> table.<\/p>\n\n\n\n
Let’s have a look at all pending activations first:<\/p>\n\n\n\n
wp db query \"SELECT * FROM wp_signups\"<\/code><\/pre>\n\n\n\n
Now that we confirmed that the user is in there, let’s specify the query further;<\/p>\n\n\n\n
wp db query \"SELECT * FROM wp_signups WHERE user_email = '{USER_EMAIL}'\"<\/code><\/pre>\n\n\n\n
(you can use any other data and column as well, the first command will give you all information.)<\/em><\/p>\n\n\n\n
Okay, so we nailed down the user – now, it’s time for deletion, we’ll change the query a bit, and execute the deletion with the following command.<\/p>\n\n\n\n
The WP-CLI command to delete a pending user from the database<\/h2>\n\n\n\n
wp db query \"DELETE FROM wp_signups WHERE user_email = {USER_EMAIL}\"<\/code><\/pre>\n\n\n\n
And there you go – the e-mail address is free to use again!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"
It’s definitely not the first time that I ran into this situation; A user was added to the website without checking the “Skip confirmation email” checkbox. Now, we’d like to force this user into the website and just send a login and password over, but now we get the message: That email address has already […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\n
Delete a pending user from WordPress - Marinus Klasen<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\n\n\t\n\t\n\t\n