Okay
  Public Ticket #3441484
Custom email to user
Closed

Comments

  • Abhi started the conversation

    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."



  •  1,904
    WebWizards replied

    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://woocommerce-b2b-plugin.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

  • Abhi replied

    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 );


  •  1,904
    WebWizards replied

    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.

  • Abhi replied

    Currently both are installed on the site 

  •  1,904
    WebWizards replied

    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://woocommerce-b2b-plugin.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