All Topics
Filter dropdown list doesn't reflect CustomField list filter changes
Hi ac team,
I’ve managed to successful use a filter (below) to changed a value ‘id’ in a custom field (I’m using Toolset btw and integration). However these values are not reflected in the filter dropdown list associated with this column. Maybe there is an option button or @param or something I am missing or something that does this.
So I’ve been playing with acp_filter_dropdown_args to try to achieve this but have been able to work out how to set these filter values. The logic I am thinking is:
(Please forgive ignorance, errors etc, not a coder, just being distracted by acPro powers).
Thanks very much.
function acp_filter_dropdown_args_course_id( $args, $column, $options ) {
//i would like this change to 'ids' in dropdowns to titles like how it works in the columns using the ac/column/value filter below.
if ( $column instanceof ACP_Column_CustomField ) {
$meta_key = $column->get_meta_key();
// This gets the Custom Field key - ?but should this be getting the 'type'?
if ( 'course_id' === $meta_key ) {
// the logic is this but how to set the array of options please?
// I can't work out the syntax for setting this array....
// for each option in the filtered column
// $args['options?/'id'?/value?'][0] => ['get_the_tile($value)'];
// $args['options?/'id'?/value'?][1] => ['get_the_tile($value)'];
return $args;
}
}
}
===
Successfully got this filter working :)
===
function ac_my_custom_field_column_value_course_id( $value, $id, $column ) {
if ( $column instanceof ACP_Column_CustomField ) {
$meta_key = $column->get_meta_key(); // This gets the Custom Field key
if ( 'course_id' == $meta_key ) {
// change the value to the tile of the course with the id in this column
$value = get_the_title($value);
}
}
return $value;
}
add_filter( 'ac/column/value', 'ac_my_custom_field_column_value_course_id', 10, 3 );
You must be logged in to reply to this topic.