Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    By default, all columns will be searched. If you want to limit that to certain columns, you can use the filter_columns Shortcode parameter as explained on https://tablepress.org/extensions/row-filter/

    Regards,
    Tobias

    Thread Starter wpbenq

    (@wpbenq)

    Thank you for replying Tobias.

    So the final shortcode will look like?

    [table-user-filtered id=XXX filter_columns="XXX" /]

    For this snippet:

    add_shortcode( 'table-user-filtered', 'tablepress_filtered_table' );
    function tablepress_filtered_table( $atts ) {
    if ( ! is_user_logged_in() ) {
        return 'Error: No user is logged in.';
      }
      $current_user = wp_get_current_user();
      $userid = $current_user->ID;
      $atts['filter'] = $userid;
      $atts['filter_full_cell_match'] = true;
      $atts['cache_table_output'] = false;
      return tablepress_get_table( $atts );
      }

    `

    Thanks

    • This reply was modified 5 years, 5 months ago by wpbenq.
    Thread Starter wpbenq

    (@wpbenq)

    I am good, the above worked!
    Thank you very much Tobias.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that Shortcode and code snippet would only filter for the user ID in the given columns.

    Instead of adding it via the Shortcode, you could also set it in the code snippet, by adding the line like

    $atts['filter_columns'] = '1,4,7';
    

    Regards,
    Tobias

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Logged in User row filtering’ is closed to new replies.