Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

Form examples

Event submissions from visitors

add_action( 'init', function () {
	cafe_register_dynamic_form( [
		'id'              => 'suggest-event',
		'field_groups'    => [ 'group_event_details' ],
		'post_type'       => 'event',
		'post_fields'     => [ 'title', 'content' ],
		'post_terms'      => [ 'event_category' ],
		'allow_guests'    => true,
		'submit_label'    => 'Suggest this event',
		'success_message' => 'Thank you! We will check your event before it is published.',
	] );
} );
[cafe_dynamic_form id="suggest-event"]

Visitors' posts are always pending; media fields are not shown to them.

"My profile" page

// page-profile.php
if ( ! is_user_logged_in() ) {
	wp_login_form();
	return;
}

cafe_dynamic_form( [
	'id'           => 'my-profile',
	'field_groups' => [ 'group_member_profile' ],
	'object_type'  => 'user',
	'object_id'    => 'current_user',
	'submit_label' => 'Save profile',
] );

Edit an event on its own page

// single-event.php
if ( current_user_can( 'edit_post', get_the_ID() ) ) {
	cafe_dynamic_form( [
		'id'           => 'edit-event',
		'field_groups' => [ 'group_event_details' ],
		'object_id'    => get_the_ID(),
		'post_fields'  => [ 'title', 'content' ],
		'redirect'     => get_permalink(),
	] );
}

A job application with a CV (for signed-in candidates)

Give the candidate role upload_files, then:

cafe_dynamic_form( [
	'id'           => 'apply',
	'field_groups' => [ 'group_application' ], // Name, motivation (Textarea), CV (File, PDF only).
	'post_type'    => 'application',
	'post_status'  => 'private',                // Candidates cannot publish → "pending".
	'redirect'     => home_url( '/applied/' ),
] );

Site settings for shop managers

cafe_dynamic_form( [
	'id'           => 'opening-hours',
	'field_groups' => [ 'group_opening_hours' ],
	'object_type'  => 'option',
	'capability'   => 'manage_woocommerce', // In addition to manage_options.
] );

Only some fields of a group

add_filter( 'cafe_dynamic_form_fields', function ( array $fields, $form ) {
	if ( 'my-profile' === $form->id ) {
		$fields = array_filter( $fields, fn ( $field ) => 'internal_notes' !== $field->name );
	}
	return $fields;
}, 10, 2 );

Submit from your own code

$result = cafe_submit_dynamic_form( 'suggest-event', [
	'post'   => [ 'title' => 'Jazz night' ],
	'fields' => [ 'venue' => 'De Kade', 'event_date' => '20261012' ],
] );

wp_send_json( $result->to_array(), $result->success ? 200 : 422 );