Public Ticket #3441484

Custom email to user

Closed
Comments
6 Tickets 1
Abhi started the conversation 3 years ago on August 22, 2023 at 12:18am

Hi i would like to know how to send the email to the user when admin rejects the user's application in b2bking 

I want email to have something like

"Thank you, but  you are not eligible for our B2B program."



2,762
KingsPlugins replied 3 years ago on August 22, 2023 at 10:30am

Hi Abhi,

Thank you for getting in touch,

You could add this PHP code snippet to your site to achieve that:

add_action('b2bking_reject_user_admin_before_delete', function($user_id){
    $user = new WP_User($user_id);
    $user_email = $user->user_email;
    $message = 'Thank you, but you are not eligible for our B2B program';
    do_action( 'b2bking_new_message', $user_email, $message, get_current_user_id(), 0 );
}, 10, 1);

A PHP snippet can be added to functions.php, or by following our guide here: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

It will send the user a message using B2BKing's "new message" emails.

Kind regards,

Stefan

6 Tickets 1
Abhi replied 3 years ago on August 30, 2023 at 1:18am

Hi Thanks for the reply i tried this code but it doesn't seem to be working. 

 i used this code in a plugin called code snippet 

As a test: I filled out the registration form and received the mail like (Your application is on hold) but even after rejecting the user, I'm not getting the mail of the user rejected. I also i checked the Mail log and i didn't see any mail related to it. Also, I would like to use the same template I'm using with all of my email 


Similar to the template i m using with this email ( Email user received after getting approved )

<?php

defined( 'ABSPATH' ) || exit;

/*
 * @hooked WC_Emails::email_header() Output the email header
 */
do_action( 'woocommerce_email_header', $email_heading, $email );

$user = get_user_by('email', $email->recipient);
$first_name = get_user_meta($user->ID, 'billing_first_name', true);

if (!empty($first_name)){
echo esc_html__('Hi ','b2bking').$first_name;
echo '<br>';
}
?>
<p>
    <?php esc_html_e( 'Congratulations! Your account has been approved.', 'b2bking'); ?>
    <br> 
<br>
    https://mysite.com/my-account/"> esc_html_e( 'Click here to login', 'b2bking' ); ?>
</p>

<?php

/**
 * Show user-defined additional content - this is set in each email's settings.
 */
if ( $additional_content ) {
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
}

/*
 * @hooked WC_Emails::email_footer() Output the email footer
 */
do_action( 'woocommerce_email_footer', $email );


2,762
KingsPlugins replied 3 years ago on August 30, 2023 at 2:09am

Can you please clarify, are you using the B2BKing Core plugin (free version), or the B2BKing Pro one? It may be related to why the snippet is not working.

2,762
KingsPlugins replied 3 years ago on August 30, 2023 at 7:13am

Thank you for clarifying.

I am not sure why the snippet did not work. Please check that you already have the latest version of B2BKing Pro installed, that is currently version 4.7.10. 

If you do not, please make sure to update: https://b2bkingplugin.com/docs/how-to-update-b2bking-to-the-latest-version/

We can also check this directly on your site if you would like to troubleshoot directly.

For that please provide us with your license key / purchase code for the plugin and your site's or staging site's access details.

Kind regards,

Stefan

Sign In