Skip to content

Instantly share code, notes, and snippets.

@will83
Last active August 8, 2018 18:03
Show Gist options
  • Save will83/856c20be6cb6d21dd1934390e2c3ffa0 to your computer and use it in GitHub Desktop.
Save will83/856c20be6cb6d21dd1934390e2c3ffa0 to your computer and use it in GitHub Desktop.
<?php
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Utilisateur']['user_id'] = 'ID utilisateur';
return $choices;
}
add_filter('acf/location/rule_values/user_id', 'acf_location_rules_values_user');
function acf_location_rules_values_user( $choices ) {
$choices[ 511 ] = 'ADMIN 2018 (511)';
return $choices;
}
add_filter('acf/location/rule_match/user_id', 'acf_location_rules_match_user', 10, 3);
function acf_location_rules_match_user( $match, $rule, $options )
{
$selected_user = (int) $rule['value'];
if($rule['operator'] == "==") {
$match = ( wp_get_current_user()->ID == $selected_user );
}
elseif($rule['operator'] == "!=") {
$match = ( wp_get_current_user()->ID != $selected_user );
}
return $match;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment