Home › Forums › Backend Issues (wp-admin) › Search ACF fields and display search results
Hi, All.
I’m hoping someone can help. I am currently using the free version but will update to pro if I can resolve this issue. I have created a new ACF field group called ‘Role Number’ with the label ‘Roll or Pension Number’ and called it ‘role_number’.
I have then added the code below to functions.php to display the new column field. What I would like to do is make this column searchable via the search box on wp-admin/users.php.
I have limited knowledge in this area but would love to learn more.
add_filter( 'manage_users_columns', 'column_register_acf_id' );
add_filter( 'manage_users_custom_column', 'column_display_acf_id', 10, 3 );
function column_register_acf_id( $columns )
{
$columns['id_col'] = 'ROLL';
return $columns;
}
function column_display_acf_id( $value, $column_name, $user_id )
{
$user_info = get_user_meta( $user_id, 'role_number', true );
if($column_name == 'id_col') return $user_info;
return $value;
}
add_action ( 'manage_users_custom_column', 'column_display_acf_id', 10, 3 );
Thanks in advance for any help
Thanks, Jemmy, for taking the time to share your code. You have an impressive profile—unfortunately, the code, when added to my funtions.php, throws up a few errors.
Parse error: syntax error, unexpected '(', expecting variable (T_VARIABLE) or '{' or '$'
Thanks, John – definitely some great reading on customizing WordPress administration Filters. I’m still searching for a way to query the columns using the search users field. With 900 members searching by roll seems the best option.
Sorry for not posting more than a link, but it’s a large topic.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.