Skip to content

Instantly share code, notes, and snippets.

@Cafnio
Last active June 19, 2020 15:06
Show Gist options
  • Save Cafnio/ec19785805ba10ec6ba0df9fb745fb74 to your computer and use it in GitHub Desktop.
Save Cafnio/ec19785805ba10ec6ba0df9fb745fb74 to your computer and use it in GitHub Desktop.
WooCommerce: Deny Automatic Login Upon Registration (Specific Roles)
//Add the following content to functions.php
function filter_woocommerce_registration_auth_new_customer( $true, $newWserId ) {
$roles = get_userdata( $newWserId )->roles;
if ( !in_array( 'customer', $roles )) {
return false;
}
return $true;
};
// add the filter
add_filter( 'woocommerce_registration_auth_new_customer', 'filter_woocommerce_registration_auth_new_customer', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment