Association field values (user type) should load previously saved users.
Instead of showing which users were selected/saved it displays nothing due to the fatal error generated in the server after the request to the REST API.
use Carbon_Fields\Container;
use Carbon_Fields\Field;
function carbon_fields_register_fields_callback() {
Container::make( 'theme_options', __( 'Pay Author Per Post', 'ss_papp' ) )
->set_page_file( 'ss_papp_settings' )
->set_page_menu_title( 'Pay Author Per Post' )
->where( 'current_user_role', 'IN', [ 'administrator' ] )
->add_tab( __( 'Configurações de pontuação', 'ss_papp' ), [
Field::make( 'association', 'papp_included_users', __( 'Usuários que pontuam', 'ss_papp' ) )
->set_help_text( __( 'Qualquer usuário selecionado acima pontuará, independentemente de qual seja sua função.', 'ss_papp' ) )
->set_types( [
[ 'type' => 'user' ]
] )
->set_visible_in_rest_api( true ),
Field::make( 'association', 'papp_excluded_users', __( 'Usuários que NÃO pontuam', 'ss_papp' ) )
->set_help_text( __( 'Qualquer usuário selecionado acima não pontuará, independentemente de qual seja sua função. Essa opção predominará caso um mesmo usuário esteja selecionado em "Usuários que pontuam".',
'ss_papp' ) )
->set_types( [
[ 'type' => 'user' ]
] )
->set_visible_in_rest_api( true )
] );
}
add_action( 'carbon_fields_register_fields', 'carbon_fields_register_fields_callback', 1 );
functions.php or inside a plugin.http://localhost if necessary.Usuários que pontuam.http://localhost/wp-json/carbon-fields/v1/association/?container_id=carbon_fields_container_pay_author_per_post&options=1%3Auser%3Auser&field_id=papp_included_users generates a fatal error:Uncaught Error: Call to a member function get_thumbnail_by_type() on null in /var/www/html/wp-content/plugins/ss-pay-author-per-post/vendor/htmlburger/carbon-fields/core/REST_API/Router.php:323. Of course, your directory will be different.I've already read the other issues that are related to Association fields, but none of them fixes my problem.
I've also had the same issue in a fresh WP installation with no plugins installed.
Please, help.
Anybody? 😢
Same problem.
No idea how to resolve. Please help
Fatal error: Uncaught Error: Call to a member function get_thumbnail_by_type() on null in /DATOS/CLIENTS/galfer/galfer.devel/theme/vendor/htmlburger/carbon-fields/core/REST_API/Router.php:323 Stack trace: #0 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/rest-api/class-wp-rest-server.php(946): Carbon_Fields\REST_API\Router->get_association_data(Object(WP_REST_Request)) #1 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/rest-api/class-wp-rest-server.php(329): WP_REST_Server->dispatch(Object(WP_REST_Request)) #2 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/rest-api.php(309): WP_REST_Server->serve_request('/carbon-fields/...') #3 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/class-wp-hook.php(286): rest_api_loaded(Object(WP)) #4 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #5 /DATOS/CLIENTS/galfer/galfer.devel/wordpress/wp-includes/plugin.php(531): WP_Hook->do_action(Array) #6 /DATOS/CLIENTS/galfer/galfer.devel/wor in /DATOS/CLIENTS/galfer/galfer.devel/theme/vendor/htmlburger/carbon-fields/core/REST_API/Router.php on line 323
Hi, this issue was already resolved. Please update to the latest Carbon Fields version.
Same issue in 3.1.20
v3.2.1 same problem
The issue should be fixed in the latest release.
If you happen to experience it again, please open a new one with more details.
Thanks!
@jorostoyanov it happens with WPML when you switch to a secondary language, not the main one.
@jorostoyanov not really a code issue, but we had in the PHP file this:
Container::make('theme_options', __('Homepage')) and that translated Homepage to Pagina de inicio and had another container id. That confused Carbon Fields.
Most helpful comment
@jorostoyanov not really a code issue, but we had in the PHP file this:
Container::make('theme_options', __('Homepage'))and that translated Homepage to Pagina de inicio and had another container id. That confused Carbon Fields.