Join our new community forum for support & discussion

Join Now

Home Support Extensions Requests Code snippet for sending notification emails to vendors

Code snippet for sending notification emails to vendors

  • Author
  • ThomasB

    Hi Ihor and team

    If possible, can you provide a codesnippet we can use to send notifications to vendors when new messages/requests from buyers appear on our site using the “Request” extension?


    ihor developer

    Please try using this one:

    	function( $request_id, $new_status, $old_status ) {
    		if ( 'publish' === $new_status && in_array( $old_status, [ 'auto-draft', 'pending' ], true ) ) {
    			$request_url = get_permalink( $request_id );
    			$users = get_users(
    					'role'   => 'contributor',
    					'number' => 100,
    			foreach ( $users as $user ) {
    					'New Request',
    							'user_name'   => $user->display_name,
    							'request_url' => $request_url,
    						'Hi, %user_name%! There is a new request, please follow this link to view it: %request_url%'

    It’s not tested, please let me know if you notice any issues. Also, it assumes that all vendors have the “contributor” role in WordPress/Users (HivePress sets this role by default).


    Thanks, we will let you know if we notice any issues 🙂


    Hello, I have a question regarding this code.
    Could it be adjusted so that the email also contains the message text / text of an offer?
    When a vendor receives an offer via the offer form on the request page I would want him to be able to read the offer text via Email already so that he doesnt necessarily need to go to the website to read it.
    I am not using the marketplace extension.

    Thank you

    ihor developer

    Please try using this token in the “New Offer” email text:



    Thank you. I mean actually vendors are already getting those emails without this script.
    Therefore I tried to adjust the email under class-offer-submit but doesnt work.
    Where and how to I have to make adjustments to show the offer text?
    Sorry I am not an dev 🙂

    Thank you for your help

    ihor developer

    Maybe you mean the request text, not the offer? The code snippet above notifies vendors about a new request, while the offer is submitted by vendors themselves.

    If you mean the email sent to users when vendors make an offer you can edit it in HivePress/Settings/Offers/Emails section, and use the %offer.text% token in the email text – this doesn’t require any code customizations.


    Hello ihor,
    Sorry, let me clarify this a bit better.

    User A: has posted a request: e.g. “Build me a WordPress Website”
    Vendor V submits an offer: “Hello, My offer is XYZ, I have great experience because of…”

    When User A now gets the email notification that he received an offer: “You received an offer. View this link…” the text which the vendor submitted should be in that email (not only on the website)

    –> “You received an offer:
    “Hello, My offer is XYZ, I have great experience because of…”
    View this link…”

    How could that be achieved?

    Thank you



    Tried to add the %offer.text% with loco translate but it stays: %offer.text% in the email

    ihor developer

    This is strange, please try adding it to the Offer Received email text (via HivePress/Settings/Offers) and try making an offer. If it doesn’t work please wait for the next Requests update (2-3 days), I’ll double-check this.


    Hello ihor. I am stupid. It works like that.
    Thank you so much for your help.


    Just a little follow up question:
    Is there a way to display the vendor’s email address and vendors username that gave the offer in that email as well (with a token or something?).

    Thank you

    ihor developer

    Sorry, it’s not possible yet, this token is not available in the New Offer email.

Viewing 13 posts - 1 through 13 (of 13 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.