Support

Account

Home Forums General Issues Value Field on user page column

Solved

Value Field on user page column

  • How i can get field on collumm?

    // Add columm
    
    function wpse_add_user_table_list_column($column) {
        $column['call_sign'] = 'Обработано?';
        return $column;
    }
    add_filter('manage_users_columns', 'wpse_add_user_table_list_column');
    
    // Sortable
    
    function wpse_user_table_list_sortable_columns($columns) {
        $columns['call_sign'] = 'call_sign';
        return $columns;
    }
    add_filter('manage_users_sortable_columns', 'wpse_user_table_list_sortable_columns');
    
    // Value field
    
    function wpse_user_table_list_column_value($val, $column_name, $user_id) {
        if('call_sign' === $column_name) {
    
              $new_value = the_field( 'hh' );
            return $new_value;
        }
        return $val;
    }
    add_filter('manage_users_custom_column', 'wpse_user_table_list_column_value', 10, 3);
    
  • First, when you want to get a value use get_field(). Second, when getting a value from an acf field for a user you need to supply the correct ID. $new_value = get_field( 'hh', 'user_'.$user_id ); https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.