Short question, this code we have created will only work for updating existing tables or will it even be called when we create new tables?
If it will work even when we create new tables then I need to adjust code so not same message will be sent.
So how can I solve to have an other message sent out when we create a brand new table?
Code looks like this at the moment:
<?php
/**
* Plugin Name: MNF Tablepress
* Plugin URI: https://mesas.se/
* Description: A custom plugin for mail notification with Tablepress.
* Version: 1.2
* Author: Per Soderman
* Author URI: https://mesas.se/
**/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
//Function to get updated tablepress to mail members a notifications
add_action( 'tablepress_event_saved_table', 'pabrady_tablepress_save_notification', 10, 1 );
function pabrady_tablepress_save_notification( $table_id ) {
$frontend_controller = TablePress::load_controller( 'frontend' );
$frontend_controller->init_shortcodes();
add_filter( 'tablepress_edit_link_below_table', '__return_false' );
$table_html = do_shortcode( "[table id={$table_id} print_name=true /]" );
$subject = do_shortcode( "[table-info id={$table_id} field=name /]" );
$subject .= " har uppdaterats!";
$mail_text = "{$table_html}.";
$headers = array('Content-Type: text/html; charset=UTF-8');
//For test
//$multiple_recipients = array('[email protected]', '[email protected]', '[email protected]');
foreach($multiple_recipients as $to)
wp_mail($to,$subject,$mail_text,$headers);
}