If your problem is:
I want to send email if a postmeta of a post is changed to the
expected value
Why do yous ask for:
How can i get the List of post id on bulk edit?
This is a typical x/y problem: when you have a problem, ask how to solve that problem, instead of asking ways to apply what you think is the solution…
Going in the details, you want to perform an action when a meta field is updated? Why don’t just look at.. the moment it is updated?
Everytime a post meta is updated, WordPress call the hook 'updated_postmeta'
like so
do_action("updated_{$type}_meta", $meta_id, $object_id, $meta_key, $meta_value);
where $type
is 'post'
.
As you can see, you have enough informations to do anything you want.
Let’s assume you want to send a mail to the post author everytime the meta ‘send_mail’ is set to ‘ok’:
add_action( 'updated_post_meta', 'listen_to_meta_change', 20, 4 );
function listen_to_meta_change( $mid, $pid, $key, $value ) {
if ( $key !== 'send_mail' ) return; // if the key is not the right one do nothing
$value = maybe_unserialize( $value );
if ( $value !== 'on' ) return; // if the value is not the right one do nothing
// if we're here, the post meta 'send_mail' was set to 'on' for a post, let's get it
$post = get_post( $pid );
if ( $post->post_type !== 'post' ) return; // maybe check for a specific post type?
$recipient = new WP_User( $post->post_author ); // get the post author
if ( ! $recipient->exists() ) return; // check if is a valid user
static $sended = array();
if ( ! isset($sended[$recipient->ID]) ) $sended[$recipient->ID] = array();
if ( isset($sended[$recipient->ID][$pid]) ) {
// already sent email for this user & post & request: that's enough, let's exit
return;
}
$sended[$recipient->ID][] = $pid;
// ok, send the email, you can write the function, by yourself, isn't it?
// be sure to have control on how many emails you send to an user:
// too much emails slow down your site and also make you a spammer...
// probably you can take control that using an user meta...
send_email_to_user_when_meta_updated( $recipient );
}
Note that this code runs only when a meta is updated, and not when is added.
To run same code when the meta is also added, just add another action:
add_action( 'added_post_meta', 'listen_to_meta_change', 20, 4 );
Both hooks work in identical way, passing identical arguments, so no problem on using same function for both.