Title: Custom post types
Last modified: August 24, 2016

---

# Custom post types

 *  Resolved [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/)
 * 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
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 15 replies - 1 through 15 (of 63 total)

1 [2](https://wordpress.org/support/topic/custom-post-types-208/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/custom-post-types-208/page/3/?output_format=md)
[4](https://wordpress.org/support/topic/custom-post-types-208/page/4/?output_format=md)
[5](https://wordpress.org/support/topic/custom-post-types-208/page/5/?output_format=md)
[→](https://wordpress.org/support/topic/custom-post-types-208/page/2/?output_format=md)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021455)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * TablePress only uses CPTs as the data storage, where the table is stored as a
   JSON-encoded string. Making those public is not useful for TablePress, and could
   actually confuse people (as they would suddenly see the JSON code).
 * Can you explain why you want the TablePress CPT to be public? (If you really 
   want this, you could achieve it by using the `tablepress_post_type_args` filter
   hook from the [model-post.php](https://github.com/TobiasBg/TablePress/blob/master/models/model-post.php)
   file.)
 * Regards,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021460)
 * This question is coming from the author of mentioned notification plugin as he
   collect the public ones. I will ask him to contact you if he need.
 * Per
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021462)
 * Reason for this is that I want to find a way to get mail notifications sent to
   certain users when I have updated table in tablepress. The mentioned plugin worked
   until recently as the author of it changed to only collect the public custom 
   post types and not the private as this created some other issues in his plugin.
 * I think I have asked you earlier if it would be possible to get tablepress to
   handle mail notifications as an extra plugin?
 * Either way is to follow your suggested way but I dont know where and how the 
   code should look like to grab tablepress custom post types. Can you help me here?
 * Per
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021466)
 * Hi Per,
 * thanks for the explanation. I don’t think that changing the visibility of the
   TablePress CPT will help for that.
 * Instead, to get a notification when a TablePress table is saved, you could simply
   use some PHP code like this
 *     ```
       add_action( 'tablepress_event_saved_table', 'pabrady_tablepress_save_notification', 10, 1 );
       function pabrady_tablepress_save_notification( $table_id ) {
         wp_mail(
           'recipient@example.com',
           'TablePress table was saved',
           "The table with the ID {$table_id} was saved."
         );
       }
       ```
   
 * (e.g. in your theme’s functions.php or in a small custom plugin.)
 * Regards,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021475)
 * Great, I will test this at once.
 * Per
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021484)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Best wishes,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021570)
 * Hi
 * Have some question:
    1. Is it possible to add in the data which was updated? 
   If so how should the code for this look like? 2. Can I add in public short codes?
 * Per
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021576)
 * Hi
 * To be added to quest no 1-2:
 * Can we add in tablepress short codes inside the mentioned code above to get the
   table presented in mail?
 * Per
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021586)
 * Hi Per,
 * 1. No, this is not possible. TablePress does not keep records about the modifications,
   so that it can not present them here 🙁
 * 2. Using Shortcodes in the mail text should be possible, but you might have to
   add a wrapping `do_shortcode()` function call around the email text. This will
   however not work for the `[table]` Shortcode as it’s not registered in this context.
   To do that, you could modify the code to
 *     ```
       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();
   
         $table_html = do_shortcode( "[table id={$table_id} /]" );
         $mail_text = "The table with the ID {$table_id} was saved: {$table_html}.";
   
         wp_mail(
           'recipient@example.com',
           'TablePress table was saved',
           $mail_text
         );
       }
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021589)
 * Hi
 * Tested the above code but then I get this error in Tablepress:
 * Saving failed: AJAX call failed: error – Internal Server Error. Try again while
   holding down the “Shift” key.
 * I even tried to save again with Shift down but then I got a blank page.
 * Per
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021591)
 * Hi,
 * ah, there’s a typo in my code, sorry.
    Please replace
 *     ```
       $frontend_controller = $TablePress::load_controller( 'frontend' );
       ```
   
 * with
 *     ```
       $frontend_controller = TablePress::load_controller( 'frontend' );
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021599)
 * Ok will change and test and report back asap how it goes.
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021612)
 * Hi
 * Its nearly working, I now get the mail but the content is with raw html codes.
   Is it possible to get this content presented as its shown in page with tables?
 * Per
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021614)
 * Hi Per,
 * no, showing the table as on the website is not really possible, as that needs
   HTML code 🙁
    The alternative would be to send the email as an HTML email instead
   of as a text email, but unfortunately, I can’t help with the modifications of
   the code for that, as I haven’t done that before.
 * Regards,
    Tobias
 *  Thread Starter [psn](https://wordpress.org/support/users/psn/)
 * (@psn)
 * [11 years ago](https://wordpress.org/support/topic/custom-post-types-208/#post-6021616)
 * Found solution with headers then mail actually present with correct table and
   not raw html codes:
 *     ```
       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();
   
         $table_html = do_shortcode( "[table id={$table_id} /]" );
         $mail_text = "The table with the ID {$table_id} was saved: {$table_html}.";
         $headers = array('Content-Type: text/html; charset=UTF-8');
   
         wp_mail(
           'per.soderman@gmail.com',
           'TablePress table was saved',
           $mail_text,
           $headers
         );
       }
       ```
   
 * Only thing which I havent been able to solve is that even Edit-link (`<a href
   ="http://www.test.se/wp-admin/admin.php?page=tablepress&action=edit&table_id=
   18">Edit</a>`) is present in mailtext so any idea how to get ride of that?

Viewing 15 replies - 1 through 15 (of 63 total)

1 [2](https://wordpress.org/support/topic/custom-post-types-208/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/custom-post-types-208/page/3/?output_format=md)
[4](https://wordpress.org/support/topic/custom-post-types-208/page/4/?output_format=md)
[5](https://wordpress.org/support/topic/custom-post-types-208/page/5/?output_format=md)
[→](https://wordpress.org/support/topic/custom-post-types-208/page/2/?output_format=md)

The topic ‘Custom post types’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 63 replies
 * 3 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/custom-post-types-208/page/5/#post-6021801)
 * Status: resolved