Okay
  Public Ticket #3508815
Decline email for "Registration - Manual Approval for All"
Closed

Comments

  •  2
    Fabian started the conversation

    Hi,

    we're currently restricting logins to our B2B shop via your plugin and the functionality "Manual Approval for All". We could translate and change the approval email accordingly to our requirements, but unfortunately, it seems like no email will be sent out if we decline the requested user during the approval process.

    Is it true that no email will be sent to the declined user? If this is the case, how can we activate such an email?

    Best Fabian

  •  2,218
    WebWizards replied

    Hi Fabian,

    By default, there is no email for that. 


    However, you can add one using this PHP code snippet:

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

    You can set the $message to anything you'd like in the above snippet.

    The snippet can be added to functions.php or to any snippets plugin,



    Kind regards,

    Stefan


  •  2
    Fabian replied

    Thanks!

    Sending a mail works, but I have three questions. I hope it's not with much effort for you to answer.


    Is it possible to...

    • hide "User: xyz" in the message? It looks confusing, that the Username is shown there from the agent which initiates the action
    • change the subject of the message (instead of "New message / conversation")?
    • to add a message with linebreaks? Either a normal line break in the variable nor "\r\n" works and the whole message get's combined in one single line (it looks messy).

    Thank you very much in advance!

  •  2,218
    WebWizards replied

    Hi Fabian,

    To hide that User: xyz area, you can change the snippet to this one:

    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...<br>new line<br>line 3';
        do_action( 'b2bking_new_message', $user_email, $message, 'Quoteemail:1', 0 );
    }, 10, 1);
    

    That would result in this message:

    6405831810.png



    Line breaks can be entered by using <br>. You can also use <b> to bold text and <a href="https://xyz"></a> to enter links.


    Regarding the title of the email (new message / conversation), this can be edited in WooCommerce -> Settings -> Emails:

    6802371770.png

    (this is a general email that is used for all message emails in the plugin).


    Kind regards,

    Stefan

  •  2
    Fabian replied

    Hi Stefan, 

    thank you very much. Everything works now as expected.

    Best
    Fabian