Never miss Magento tips, tricks, tutorials, and news.
Use the above solution and stop the unauthenticated user in your store or else, you could just use the Magento 2 Restrict Fake Registration extension!
The below code is the method for the same:
Method to Programmatically Check if Customer Account is Confirmed or not in Magento 2
Magento 2 store owners tend to collect customers’ data for various purposes such as marketing, understanding customers’ behaviour and shopping pattern, or simply offer a better user experience.
class Data extends AbstractHelper
public function __construct(
$this->accountManagement = $accountManagement;
public function isAccountConfirmed($customerId)
Any doubts about the topic can be mentioned in the Comments section below. I’d be happy to help.
Something went wrong.
Use the below code in the helper file.
Thank you for subscribing.
Also, please share the tutorial with the Magento community via social media.
isAccountConfirmed() function returns result as :
Get Weekly Updates
However, when you programmatically login customer without a password, in that case even if the email is not confirmed, the customer can log in. In this situation, you need to programmatically check if customer account is confirmed or not in Magento 2.
Apart from collecting customers’ data is to collect their Email ID while registering with Magento 2 store. Every store owner usually confirms if the given Email ID is correct or not.