Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $value = apply_filters( "pre_update_option_{$option}", $new_value, $old_value );
- $value = apply_filters( 'pre_update_option', $value, $option, $old_value );
- <?php
- /** Plugin Name: (#16621) Send mail after Option Value changed */
- add_action( 'plugins_loaded', '166221reactMail' );
- function 166221reactMail()
- {
- // @TODO Add you option names (valid triggers) here:
- $valid = [
- 'your',
- 'option',
- 'names',
- 'here',
- ];
- // Attach each filter: Precise targetting option names
- foreach ( $valid as $name )
- {
- add_filter( "pre_update_option_{$name}", function( $new, $old )
- {
- # @TODO Adjust check/validity of mail trigger here
- if ( $new !== $old )
- {
- # @TODO uncomment the following line - see note below
- // add_filter( 'wp_mail_from', '166221reactMailFrom' );
- # @TODO Adjust values for wp_mail()
- wp_mail(
- 'To@example.com',
- sprintf( 'Change notification from %s', get_option( 'blogname' ) ),
- sprintf( 'Value changed from %s to %s', $old, $new )
- );
- }
- return $new;
- }
- }
- }
- // @TODO Change "from" Name to make creating inbox rules easier
- function 166221reactMailFrom( $from )
- {
- remove_filter( current_filter(), __FUNCTION__ );
- return "foo@bar.com";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement