I have the following code snippet in /woocommerce/emails/customer-new-account.php:
// Get the user ID associated with the mail $user = get_user_by('login', $user_login ); $user_id = $user->ID;
// Check if $user_id is not empty before calling is_b2b_user() if ($user_id) { if (b2bking()->is_b2b_user($user_id)) { echo "<br>B2B user.<br>"; } else { echo "<br>Not a B2B User.<br>"; } } else { // Handle the case where $user_id is empty (e.g., guest customer) echo "<br>Guest customer (not registered).<br>"; }
Unfortunately, even for Not-Yet-Approved B2B-Users, the output of b2bking()->is_b2b_user($user_id) is false, therefore "Not a B2B User.
The expected output would be true, since we still have to handle him like a b2b-user. Is there a fix or workaround for this?
Hello,
I have the following code snippet in /woocommerce/emails/customer-new-account.php:
// Get the user ID associated with the mail
$user = get_user_by('login', $user_login );
$user_id = $user->ID;
// Check if $user_id is not empty before calling is_b2b_user()
if ($user_id) {
if (b2bking()->is_b2b_user($user_id)) {
echo "<br>B2B user.<br>";
} else {
echo "<br>Not a B2B User.<br>";
}
} else {
// Handle the case where $user_id is empty (e.g., guest customer)
echo "<br>Guest customer (not registered).<br>";
}
Unfortunately, even for Not-Yet-Approved B2B-Users, the output of b2bking()->is_b2b_user($user_id) is false, therefore "Not a B2B User.
The expected output would be true, since we still have to handle him like a b2b-user. Is there a fix or workaround for this?
Thank you!
Attached files: Screenshot 2024-04-23 at 18.53.35.png
Screenshot 2024-04-23 at 18.53.07.png
Hello Christian,
Thank you for purchasing our plugin,
Indeed that function only returns true for approved B2B users.
If you would like to make that also accept accounts pending approval, you can change your code as follows:
Replace this line:
with:
Let me know if that can solve it for you,
Kind regards,
Stefan
Thank you, that worked perfectly!