Okay
  Public Ticket #3021920
when user sign up they cant access Agents Dashboard Page
Closed

Comments

  • commaenvato started the conversation

    when users sign up they cant access the Agents Dashboard Page because they are signed up as a Customer, not an agent, who can I make anyone who signs up get to be an agent automatically.

  •  1,906
    WebWizards replied

    Hi there,

    Thank you for purchasing our plugin,


    I understand that you'd like to set up an agents registration page, so users can register and automatically become agents.

    For this, all that has to be done is that some meta data needs to be set for the user. You need to set 2 meta keys for the user:

    - salesking_user_choice needs to have the value agent

    - salesking_group needs to have the value of an agent group ID (E.g 1234 )


    If you use some registration plugin to create a registration form, many registration / forms plugins also have an option to set meta data. See this for example with the WPForms plugin: https://wpforms.com/docs/how-to-set-up-custom-user-meta-fields/


    Or if you want, we also have a B2BKing plugin ( https://1.envato.market/NMWbV  ) that has a registration feature. It is connected with SalesKing and you can use it to set up an agent registration page.


    Kind regards,

    Stefan

  • commaenvato replied

    there is no registration page anyone who can access my site will sign up with Google directly, so I need a way to make these users that signed in with google automatically become agents.

    in other words

    What I am trying to achieve is letting agents automatically be approved without any actions from my side. I don't allow agents signup through a registration form I only allow them to use Social login (google account).

  •  1,906
    WebWizards replied

    I have a suggestion in that case. Perhaps we can set it so that whenever a user logs in, they automatically become an agent. I wrote a code snippet to do that. Please add the following snippet to your site:

    add_action('wp_login', function($username, $user) {
        // First need to get the user object
        if (!empty($username)){
            $user = get_user_by('login', $username);
            if(!$user) {
                $user = get_user_by('email', $username);
                if(!$user) {
                    return;
                }
            }
        }
        if (isset($user->ID)){
            // set the user to be an agent
            update_user_meta($user->ID,'salesking_user_choice', 'agent');
            update_user_meta($user->ID,'salesking_group', 1234);
        }
    }, 10, 2);
    

    In the above snippet, you need to replace 1234 with an agent group ID. To get an ID, go to SalesKing -> Groups and click on a group. The number in the URL (e.g. ?post=1234) is the ID.


    A PHP 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/


    Let me know if that helps,