This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// As a prerequisite, there are stored each user ID to the "user_id" column (as numric type) in the "your_table_name" as target table. | |
// (対象テーブル「your_table_name」には「user_id」カラム(数値型)にユーザーIDが格納されているという前提) | |
function custom_filter_get_data_sql( $sql, $table_name, $sql_clauses ) { | |
if ( ! is_admin() && "your_table_name" === $table_name ) { | |
$_current_user_id = 0; // For guest user | |
if ( is_user_logged_in() ) { | |
$current_user = wp_get_current_user(); | |
$_current_user_id = $current_user->ID; |
NewerOlder