Email event "Listing Approved" it is not sended to user if is not checked as Manually approve new listings

Email event “Listing Approved” it is not sended to user if is not checked as Manually approve new listings.

I need to send that email, even if I don’t have “Manually approve new listings” checked.

It’s a bug. Since it is not divided, maybe make a new event “Listing Added” or something similar. Or enable sending for both.

Steps to reproduce

/wp-admin/admin.php?page=hp_settings
image

Maybe error because Recipient is Vendor, not User

Hi,

Please note that this is not a bug, but thank you for letting us know. This email is used only for listing approval if the manual listing moderation function is activated. If moderation is disabled, the user simply posts a listing, which is immediately displayed on the page, so no email is required.

Also, if you need a different email for any other event, it will require a custom implementation.

Could you please let me know a hivepress function name? So that I have something to grasp how to program it

If you’re familiar with coding, please try adding a custom function to the hivepress/v1/models/listing/update_status hook. This way you can check when the status is changed from auto-draft to publish, this is a moment when the listing is published (with moderation disabled) so you can send a custom email with wp_mail() – Function | Developer.WordPress.org

Hope this helps

@ihor Yes i am sending via wp_mail But I wanted it via the hivepress func. Because I don’t know how to get the url address of the listing. There is a token %listing_url% for that… but how do I get the url of the lisitng when I send an email via wp_mail?

Hi,

We recommend that you check this documentation Action: hivepress/v1/models/{model_name}/update_status | HivePress Hook Reference, specifically, the first parameter of this function, using it and get_permalink($listing_id), for example, you will be able to receive links. As for email customization, it requires advanced customization, so we recommend considering the wp_mail function.

Hi thanks a lot, i am tried write this code but critical error, whats wrong pls?

add_action(
 'hivepress/v1/models/listing/update_status',
 function($object_id, $new_status, $old_status, $object){
  if ($new_status !== 'publish') {
    return;
  }

  $user_id = get_current_user_id();
  
  if(!$user_id){
   return;
  }
	 
  $headers = array(
    'Content-Type: text/html; charset=UTF-8', // Set the correct Content-Type
  );
  
  $user = \HivePress\Models\User::query()->get_by_id($user_id);
  
  if(!$user || !$user->get_email()){
   return;
  }
  
  $listing_url = get_permalink($object_id); // get URL link
  
  wp_mail($user->get_email(), 'Subject', '<p>Hello,</p>
  <p>Your listing <a href="' . $listing_url . '">' . $listing_url . '</a></p>',
        $headers // Add the headers
    );
}, 1000);

Hi,

Unfortunately, we can’t help with fixing your third-party code, we can only provide general guidance.