Home / Admin / Let Customers Select Their User Role From A Custom Field In Wholesale Lead Capture
Duplicate Snippet

Embed Snippet on Your Site

Let Customers Select Their User Role From A Custom Field In Wholesale Lead Capture

Create a custom field with the user role selection, make sure that the values match your wholesale roles under Wholesale->Roles.

Add the following snippet (changing the wwlc_cf_select_role to match your custom field).

Code Preview
php
<?php
function wws_wwlc_auto_select_role ($user) {
    //get the selected role
    $selected_role = get_user_meta($user->ID, 'wwlc_cf_select_role', true); // Change to match your custom field.
    $defaultRole = get_option( 'wwlc_general_new_lead_role' );
    if ($selected_role) {
        $user->remove_role( $defaultRole );
        $user->add_role( $selected_role );
    }
}
add_action( 'wwlc_action_after_approve_user', 'wws_wwlc_auto_select_role' );

Comments

Add a Comment