Custom post types
-
Hi Tobias,
I’m using another plugin called Better Notifications for WordPress and this plugin use now public custom post types. For some reason Tablepress custom post types seems not be public. is there any reason to have these set as private?
If not can it be changed to get this as public?
Per
-
Hi,
ah, cool! 🙂
To hide the “Edit” link, please try adding
add_filter( 'tablepress_edit_link_below_table', '__return_false' );before
$table_html = do_shortcode( "[table id={$table_id} /]" );Regards,
TobiasGreat, that did the trick :-).
Now a final question: If I want to even show Table name in mail text right now its just stated ID 18 which is not telling users anything.
Per
Hi Per,
how about
$table_html = do_shortcode( "[table id={$table_id} print_name=true /]" );?
Regards,
TobiasBrilliant 🙂 that did the final part, great support!!!
Per
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
TobiasI have now also created a very small working plugin, not so fancy but working. I will try later to even create the setup of mail addresses into a separate setting page inside plugin rather then hard code directly in file.
I hope I can use your expertise if I have any questions around this?
Per
Hi
Now have I got stucked as I’m trying to get mail sent out to multiple addresses and using this code:
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 /]" ); $mail_text = "The table with the ID {$table_id} was saved: {$table_html}."; $headers = array('Content-Type: text/html; charset=UTF-8'); $multiple_recipients = array( 'test@home.se', 'test@mesas.se', 'test@gmail.com' ); wp_mail( $multiple_recipients, 'Tablepress have been saved', $mail_text, $headers ); }Can you see if something in above is incorrect placed as I dont get any mail and I dont get any error either.
Hi,
I can’t really see anything wrong directly, but I’m not that familiar with the
wp_mail()function. Sorry 🙁
You could alternatively maybe do this in a loop (i.e. send separate emails).Regards,
TobiasOk do you mean to setup several wp-mail() including each mail address or how should loop look like?
Can this work as loop
foreach $multiple_recipients as $to {
wp-mail($to, ‘Tablepress have been saved’ , $mail_text, $headers);
}Per
Now at last its all solved with correct foreach loop and also got correct setting for SMTP sending. So now I get all mail as we should 🙂
Per
Hi Per,
awesome! That’s great news! Yes, that’s how I had envisioned that loop.
Best wishes,
TobiasHi,
We have now got all code working but I need to ask one more question for the wp_mail() which have a static subject right now. I would like rather to have a dynamic subject ie Table name instead of Tablepress table has been saved”.
//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 /]" ); $mail_text = "Following has been updated: {$table_html}."; $headers = array('Content-Type: text/html; charset=UTF-8'); $multiple_recipients = array('test1@home.se','test2@home.se','test3@home.com'); foreach($multiple_recipients as $to) wp_mail($to,'Tablepress table has been updated',$mail_text,$headers); }Hi,
You could use the
[table-info]Shortcode for that, i.e. set the subject with something like$subject = do_shortcode( "[table-info id={$table_id} field=name /]" );Regards,
TobiasThxs Tobias!
This did the trick.
//Per
The topic ‘Custom post types’ is closed to new replies.