• Resolved psn

    (@psn)


    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/

Viewing 15 replies - 31 through 45 (of 63 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great! That’s good to hear!

    Best wishes,
    Tobias

    Thread Starter psn

    (@psn)

    Hi

    I have one question around to get email addresses not hard coded. I have a plugin called Page Security which we use to create a members group and in db I have a table called wp_ps_group_relationships where we have a group id connected to each users id so all members are in group id 2 and to get these users email address I need even to connect to table wp_users. Normally I should use a select join query against these 2 tables to collect members email but as WP use a certain code I wonder if you can help me out here?

    The wp_ps_group_relationships structure is very simple:

    ID	grel_group_id	grel_user_id
    1	2	6
    2	2	3
    3	2	5
    4	2	4
    5	2	7
    6	2	2

    grel_group_id is the member group and grel_user_id is the user id which can be found in wp_users. Any help would be great here!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sorry, I’m not that familiar with such SQL queries and can’t really help with that πŸ™

    Regards,
    Tobias

    Thread Starter psn

    (@psn)

    Ok thxs anyway I will search further. Have a nice evening!

    Per

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    your best chance is probably to ask the developers of that other plugins, as they know the database table structure best.

    Best wishes,
    Tobias

    Thread Starter psn

    (@psn)

    Yes have done that but they only support bug issues so I have dropped a quest in How-To section as well.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ah, I see… That’s not really cool by them. I hope that you can find a solution!

    Best wishes,
    Tobias

    Thread Starter psn

    (@psn)

    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: http://mesas.se/
    * Description: A custom plugin for mail notification with Tablepress.
    * Version: 1.2
    * Author: Per Soderman
    * Author URI: http://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('test@gmail.com', 'test1@gmail.com', 'test2@gmail.com');
    
      foreach($multiple_recipients as $to)
      wp_mail($to,$subject,$mail_text,$headers);
    }

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    this should only apply to edited/modified tables, but not to newly added tables.
    If you want notifications on those, you can hook into the tablepress_event_added_table hook.

    Regards,
    Tobias

    Thread Starter psn

    (@psn)

    Ok which means like this:

    //Function to get new tablepress to mail members a notifications
    add_action( 'tablepress_event_added_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 .= " have been created!";
      $mail_text = "{$table_html}.";
      $headers = array('Content-Type: text/html; charset=UTF-8'); 
    
      //For test
      //$multiple_recipients = array('test@gmail.com', 'test1@gmail.com', 'test2@gmail.com');
    
      foreach($multiple_recipients as $to)
      wp_mail($to,$subject,$mail_text,$headers);
    }

    and save this code direct below the existing?

    Per

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    almost. You should change the function name pabrady_tablepress_save_notification to something new as well (twice).

    Regards,
    Tobias

    Thread Starter psn

    (@psn)

    OK thxs Tobias will test and let you know if it will work.

    Per

    Thread Starter psn

    (@psn)

    Works but I realize that notification goes out to early as the table structure isn’t created so question is if its possible to have a function that generate notification which is only used first time with save?

    Per

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    what do you mean with “the table structure isn’t created”?

    Regards,
    Tobias

    Thread Starter psn

    (@psn)

    Like headings, if footer should be used etc ie all type of options and css styling.

    I was thinking if it could be possible to use creation date = today() but when I check in each table its only Last modified but I assume we should have date when it was created as well.

    Any thoughts how this can be solved?

    Per

Viewing 15 replies - 31 through 45 (of 63 total)
  • The topic ‘Custom post types’ is closed to new replies.