Magento 2: how to enable and disable customer?Magento2 : Best way to load Customer by customer Idvalidating is_unique property for custom attribute in customer registration formHow to disable customer?magento2: Enable and Disable logMagento 2 : How to disable/enable payment method based on customer?Magento 2: How to override newsletter Subscriber modelMagento 2 Add new field to Magento_User admin formMagento 2.2: How to completely disable customer login and registrationHow to add a register form inside the login popup during the checkoutDisable customer registration and loginMagento 2 How to disable price from orders, customer account and order view if custom module is enabled?

Visiting the UK as unmarried couple

Superhero words!

What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?

Could solar power be utilized and substitute coal in the 19th century?

Simulating a probability of 1 of 2^N with less than N random bits

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

Installing PowerShell on 32-bit Kali OS fails

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Is there a problem with hiding "forgot password" until it's needed?

Golf game boilerplate

Giant Toughroad SLR 2 for 200 miles in two days, will it make it?

I2C signal and power over long range (10meter cable)

What is the term when two people sing in harmony, but they aren't singing the same notes?

Are taller landing gear bad for aircraft, particulary large airliners?

Stereotypical names

Why isn't KTEX's runway designation 10/28 instead of 9/27?

How to deal with or prevent idle in the test team?

Does "Dominei" mean something?

Organic chemistry Iodoform Reaction

Should a half Jewish man be discouraged from marrying a Jewess?

Partial sums of primes

Can I create an upright 7-foot × 5-foot wall with the Minor Illusion spell?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

Why are on-board computers allowed to change controls without notifying the pilots?



Magento 2: how to enable and disable customer?


Magento2 : Best way to load Customer by customer Idvalidating is_unique property for custom attribute in customer registration formHow to disable customer?magento2: Enable and Disable logMagento 2 : How to disable/enable payment method based on customer?Magento 2: How to override newsletter Subscriber modelMagento 2 Add new field to Magento_User admin formMagento 2.2: How to completely disable customer login and registrationHow to add a register form inside the login popup during the checkoutDisable customer registration and loginMagento 2 How to disable price from orders, customer account and order view if custom module is enabled?













1















I am looking for code how the customer can be enabled and disabled using customer Id in Magento 2.



When customer is disabled we should not allow customer to login from front end.



I tried setting is_active column as 0 in Database then also i can able to login from frontend.



I am using below code



 public function execute()
$user = $this->customerFactory->create();
$userId = $this->getRequest()->getParam('user_id', false);
$status = 0;
if($userId):
$user->load($userId)->setWebsiteId($oldUser->getWebsiteId());
endif;
try
$user->setIsActive($status);
$user->save();
catch (Exception $e)
$this->_messageManager->addError(__('Can't save user'));




is that can be done pro grammatically?










share|improve this question
























  • there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

    – Ansar Husain
    Aug 9 '18 at 12:47











  • It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

    – jafar pinjar
    Aug 9 '18 at 12:55












  • it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

    – Ansar Husain
    Aug 9 '18 at 13:02











  • How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

    – jafar pinjar
    Aug 9 '18 at 13:06











  • magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

    – Ansar Husain
    Aug 9 '18 at 13:15















1















I am looking for code how the customer can be enabled and disabled using customer Id in Magento 2.



When customer is disabled we should not allow customer to login from front end.



I tried setting is_active column as 0 in Database then also i can able to login from frontend.



I am using below code



 public function execute()
$user = $this->customerFactory->create();
$userId = $this->getRequest()->getParam('user_id', false);
$status = 0;
if($userId):
$user->load($userId)->setWebsiteId($oldUser->getWebsiteId());
endif;
try
$user->setIsActive($status);
$user->save();
catch (Exception $e)
$this->_messageManager->addError(__('Can't save user'));




is that can be done pro grammatically?










share|improve this question
























  • there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

    – Ansar Husain
    Aug 9 '18 at 12:47











  • It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

    – jafar pinjar
    Aug 9 '18 at 12:55












  • it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

    – Ansar Husain
    Aug 9 '18 at 13:02











  • How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

    – jafar pinjar
    Aug 9 '18 at 13:06











  • magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

    – Ansar Husain
    Aug 9 '18 at 13:15













1












1








1








I am looking for code how the customer can be enabled and disabled using customer Id in Magento 2.



When customer is disabled we should not allow customer to login from front end.



I tried setting is_active column as 0 in Database then also i can able to login from frontend.



I am using below code



 public function execute()
$user = $this->customerFactory->create();
$userId = $this->getRequest()->getParam('user_id', false);
$status = 0;
if($userId):
$user->load($userId)->setWebsiteId($oldUser->getWebsiteId());
endif;
try
$user->setIsActive($status);
$user->save();
catch (Exception $e)
$this->_messageManager->addError(__('Can't save user'));




is that can be done pro grammatically?










share|improve this question
















I am looking for code how the customer can be enabled and disabled using customer Id in Magento 2.



When customer is disabled we should not allow customer to login from front end.



I tried setting is_active column as 0 in Database then also i can able to login from frontend.



I am using below code



 public function execute()
$user = $this->customerFactory->create();
$userId = $this->getRequest()->getParam('user_id', false);
$status = 0;
if($userId):
$user->load($userId)->setWebsiteId($oldUser->getWebsiteId());
endif;
try
$user->setIsActive($status);
$user->save();
catch (Exception $e)
$this->_messageManager->addError(__('Can't save user'));




is that can be done pro grammatically?







magento2 customer customer-account






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 12 at 11:33









WaPoNe

90311125




90311125










asked Aug 9 '18 at 10:06









jafar pinjarjafar pinjar

735414




735414












  • there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

    – Ansar Husain
    Aug 9 '18 at 12:47











  • It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

    – jafar pinjar
    Aug 9 '18 at 12:55












  • it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

    – Ansar Husain
    Aug 9 '18 at 13:02











  • How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

    – jafar pinjar
    Aug 9 '18 at 13:06











  • magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

    – Ansar Husain
    Aug 9 '18 at 13:15

















  • there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

    – Ansar Husain
    Aug 9 '18 at 12:47











  • It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

    – jafar pinjar
    Aug 9 '18 at 12:55












  • it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

    – Ansar Husain
    Aug 9 '18 at 13:02











  • How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

    – jafar pinjar
    Aug 9 '18 at 13:06











  • magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

    – Ansar Husain
    Aug 9 '18 at 13:15
















there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

– Ansar Husain
Aug 9 '18 at 12:47





there is little big process for doing this batter use free module for ithttps://github.com/amitshree/magento2-account-approval

– Ansar Husain
Aug 9 '18 at 12:47













It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

– jafar pinjar
Aug 9 '18 at 12:55






It is not correct if we set is_active to 0 in customer_entity table? This module is not my requirement

– jafar pinjar
Aug 9 '18 at 12:55














it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

– Ansar Husain
Aug 9 '18 at 13:02





it will not work with only set that attribute , you will have to use observer in registration time to check customer approved then login other wise logout it and redirect in same page with not active message same is for login condition you will have to create observer to check customer approved then continue login other wise logout and display message for not logged in like that process you will have to do

– Ansar Husain
Aug 9 '18 at 13:02













How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

– jafar pinjar
Aug 9 '18 at 13:06





How to check customer is approved or not using customer Id? Because in my controller i get customer id with drop down value enable or disable, Using id i need to implement that functionality,

– jafar pinjar
Aug 9 '18 at 13:06













magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

– Ansar Husain
Aug 9 '18 at 13:15





magento.stackexchange.com/questions/132577/… use this code to load customer by id then get attribute value $is_active=$customer->getCustomAttribute('is_active');

– Ansar Husain
Aug 9 '18 at 13:15










1 Answer
1






active

oldest

votes


















0














I am afraid that without customization you cannot disable a customer in Magento2 as discussed here.



However, you can use Disable Customer developed by "STee Extensions" to easily deactivate a customer access on the frontend website, and of-course you can always reactivate them. Once deactivated, no data will be erased from the customer account.





share






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237784%2fmagento-2-how-to-enable-and-disable-customer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I am afraid that without customization you cannot disable a customer in Magento2 as discussed here.



    However, you can use Disable Customer developed by "STee Extensions" to easily deactivate a customer access on the frontend website, and of-course you can always reactivate them. Once deactivated, no data will be erased from the customer account.





    share



























      0














      I am afraid that without customization you cannot disable a customer in Magento2 as discussed here.



      However, you can use Disable Customer developed by "STee Extensions" to easily deactivate a customer access on the frontend website, and of-course you can always reactivate them. Once deactivated, no data will be erased from the customer account.





      share

























        0












        0








        0







        I am afraid that without customization you cannot disable a customer in Magento2 as discussed here.



        However, you can use Disable Customer developed by "STee Extensions" to easily deactivate a customer access on the frontend website, and of-course you can always reactivate them. Once deactivated, no data will be erased from the customer account.





        share













        I am afraid that without customization you cannot disable a customer in Magento2 as discussed here.



        However, you can use Disable Customer developed by "STee Extensions" to easily deactivate a customer access on the frontend website, and of-course you can always reactivate them. Once deactivated, no data will be erased from the customer account.






        share











        share


        share










        answered 3 mins ago









        Saad TaimoorSaad Taimoor

        694




        694



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237784%2fmagento-2-how-to-enable-and-disable-customer%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Disable / Remove link to Product Items in Cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I limit products that can be bought / added to cart?Remove item from cartHide “Add to Cart” button if specific products are already in cart“Prettifying” the custom options in cart pageCreate link in cart sidebar to view all added items After limit reachedLink products together in checkout/cartHow to Get product from cart and add it againHide action-edit on cart page if simple productRemoving Cart items - ObserverRemove wishlist items when added to cart

            Helsingin valtaus Sisällysluettelo Taustaa | Yleistä sotatoimista | Osapuolet | Taistelut Helsingin ympäristössä | Punaisten antautumissuunnitelma | Taistelujen kulku Helsingissä | Valtauksen jälkeen | Tappiot | Muistaminen | Kirjallisuutta | Lähteet | Aiheesta muualla | NavigointivalikkoTeoksen verkkoversioTeoksen verkkoversioGoogle BooksSisällissota Helsingissä päättyi tasan 95 vuotta sittenSaksalaisten ylivoima jyräsi punaisen HelsinginSuomalaiset kuvaavat sotien jälkiä kaupungeissa – katso kuvat ja tarinat tutuilta kulmiltaHelsingin valtaus 90 vuotta sittenSaksalaiset valtasivat HelsinginHyökkäys HelsinkiinHelsingin valtaus 12.–13.4. 1918Saksalaiset käyttivät ihmiskilpiä Helsingin valtauksessa 1918Teoksen verkkoversioTeoksen verkkoversioSaksalaiset hyökkäävät Etelä-SuomeenTaistelut LeppävaarassaSotilaat ja taistelutLeppävaara 1918 huhtikuussa. KapinatarinaHelsingin taistelut 1918Saksalaisten voitonparaati HelsingissäHelsingin valtausta juhlittiinSaksalaisten Helsinki vuonna 1918Helsingin taistelussa kaatuneet valkokaartilaisetHelsinkiin haudatut taisteluissa kaatuneet punaiset12.4.1918 Helsingin valtauksessa saksalaiset apujoukot vapauttavat kaupunginVapaussodan muistomerkkejä Helsingissä ja pääkaupunkiseudullaCrescendo / Vuoden 1918 Kansalaissodan uhrien muistomerkkim

            Adjektiivitarina Tarinan tekeminen | Esimerkki: ennen | Esimerkki: jälkeen | Navigointivalikko