
Has this been solved? I am very close to getting this working, but I cannot get the AJAX aspect to work.I see that you said the post_meta needs to be updated, but I am unsure how to do that. Here is the code that I have. Everything works great except for the AJAX updating. Can you please help me.
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices )
{
$choices['Page']['customtemplate'] = 'Custom Template';
return $choices;
}
add_filter('acf/location/rule_values/customtemplate', 'acf_location_rules_values_user');
function acf_location_rules_values_user( $choices ){
$uploads = get_template_directory();
if ($dir = opendir($uploads.'/productstype')) {
$images = array();
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
$images[] = $file;
}
}
closedir($dir);
}
foreach($images as $image) {
$image = str_replace(".php", "", $image);
$choices[ $image ] = $image;
}
return $choices;
}
add_filter('acf/location/rule_match/customtemplate', 'acf_location_rules_match_user', 10, 3);
function acf_location_rules_match_user( $match, $rule, $options ){
global $post;
$current_user = get_post_meta( $post->ID, 'page_template_productstype_select', true );
//$selected_user = (int) $rule['value'];
if($rule['operator'] == "=="){
if($current_user == $rule['value'] ){
$match = true;
}else{
$match = false;
}
}elseif($rule['operator'] == "!="){
if($current_user == $rule['value'] ){
$match = false;
}else{
$match = true;
}
}
return $match;
}