Okay
  Public Ticket #3721503
Auto add customer account as agent
Closed

Comments

  •  3
    Darius started the conversation

    How?

  •  2,218
    WebWizards replied

    Hello Darius,

    Can you please clarify, do you mean that you'd like all accounts that register on the site to automatically become agents? What registration form are you using, can you share a link please?


    Kind regards,

    Stefan

  •  3
    Darius replied

    yes. i wanted all accounts register and customers accounts all auto become agents. just normal woocommerce registration form

  •  2,218
    WebWizards replied

    Thanks for clarifying,

    We can achieve this by adding the following PHP snippet to the site:

    function set_salesking_user_meta($user_id) {
        update_user_meta($user_id, 'salesking_user_choice', 'agent');
        update_user_meta($user_id, 'salesking_group', '1234');
    }
    add_action('user_register', 'set_salesking_user_meta', 10, 1);
    add_action('woocommerce_created_customer', 'set_salesking_user_meta', 10, 1);
    

    In the above code, we need to change 1234 with the ID of the salesking group. To find that ID, please go to the backend SalesKing groups page, edit the group, and check the number in the URL (e.g. ?post=1234), that number is the ID.


    The snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


  •  3
    Darius replied

    thanks. working perfectly.