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

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

            Aasi (pallopeli) Navigointivalikko