Quantcast
Channel: Topic Tag: database | WordPress.org
Viewing all articles
Browse latest Browse all 11075

ka2 on "[Plugin: Custom Database Tables] show data table by user id"

$
0
0

Thank you for your inquiry.

It will be possible to do by following.

1. Firstly, it'll add a filter into 909th line of plugin core class (lib/cdbt.class.php).

$where_clause = apply_filters( 'cdbt_get_data_conditions', $where_clause, $table_name, $conditions );

2. Next, please enabled a filter by "functions.php" of your theme into the user access page (post to use the shortcode cdbt-view).

function custom_get_data_conditions( $where_clause, $table_name, $conditions ){
  $current_user = wp_get_current_user();

  if ('your_created_table' === $table_name) {
    if (empty($conditions)) {
      $where_clause = sprintf( "WHERE userID = %d ", $current_user->ID);
    } else {
      $where_clause .= sprintf( "AND userID = %d ", $current_user->ID);
    }
  }
  return $where_clause;
}
add_filter( 'cdbt_get_data_conditions', 'custom_get_data_conditions', 10, 3);

Please try by all means.
Thank you,


Viewing all articles
Browse latest Browse all 11075

Trending Articles