"Filter: bricks/query_filters/index_user/meta_exists"
تعیین میکند که آیا یک فیلد سفارشی (کلید متا) برای یک کاربر خاص در طول فرآیند نمایه سازی وجود دارد یا خیر. این زمانی استفاده میشود که یک ارائهدهنده شخص ثالث (مانند ACF یا Meta Box) انتخاب شده باشد تا از فهرستبندی فیلدهای خالی یا ناموجود برای کاربران جلوگیری شود.
پارامترها
$exists(bool): Whether the meta key exists. Default isfalse.$user_id(int): The ID of the user being checked.$meta_key(string): The meta key of the custom field.$provider(string): The data provider (e.g.,acf,metabox).
نمونه استفاده
add_filter( 'bricks/query_filters/index_user/meta_exists', function( $exists, $user_id, $meta_key, $provider ) {
// Example: Custom check for a serialized meta field on a user
if ( $meta_key === 'user_custom_data' ) {
$data = get_user_meta( $user_id, $meta_key, true );
return ! empty( $data );
}
return $exists;
}, 10, 4 );