Home › Forums › Backend Issues (wp-admin) › My acf_form is saving to the database but not showing up in the admin panel unde
When I fill out the form on the front end, it saves to the database (confirmed through phpmyadmin) but does not show up in the admin panel. Custom Post type:
function custom_post_dog() {
$labels = array(
'name' => _x( 'Dogs', 'post type general name' ),
'singular_name' => _x( 'Dog', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Dog' ),
'edit_item' => __( 'Edit Dog' ),
'new_item' => __( 'New Dog' ),
'all_items' => __( 'All Dogs' ),
'view_item' => __( 'View Dog' ),
'search_items' => __( 'Search Dogs' ),
'not_found' => __( 'No dogs found' ),
'not_found_in_trash' => __( 'No dogs found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Dogs'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our dogs and dog specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'dog', $args );
}
add_action( 'init', 'custom_post_dog' );
Form code:
acf_form_head();
$options = array(
/* (string) Unique identifier for the form. Defaults to 'acf-form' */
'id' => 'add-dog-form',
/* (int|string) The post ID to load data from and save data to. Defaults to the current post ID.
Can also be set to 'new_post' to create a new post on submit */
'post_id' => new_post,
/* (array) An array of post data used to create a post. See wp_insert_post for available parameters.
The above 'post_id' setting must contain a value of 'new_post' */
'new_post' => array(
'post_type' => 'dog',
'post_status' => 'published'
),
/* (array) An array of field group IDs/keys to override the fields displayed in this form */
'field_groups' => false,
/* (array) An array of field IDs/keys to override the fields displayed in this form */
//'fields' => array(1,2,3,4),
/* (boolean) Whether or not to show the post title text field. Defaults to false */
'post_title' => true,
/* (boolean) Whether or not to show the post content editor field. Defaults to false */
'post_content' => false,
/* (boolean) Whether or not to create a form element. Useful when a adding to an existing form. Defaults to true */
'form' => true,
/* (array) An array or HTML attributes for the form element */
//'form_attributes' => array(),
/* (string) The URL to be redirected to after the form is submit. Defaults to the current URL with a GET parameter '?updated=true'.
A special placeholder '%post_url%' will be converted to post's permalink (handy if creating a new post) */
'return' => '',
/* (string) Extra HTML to add before the fields */
'html_before_fields' => '',
/* (string) Extra HTML to add after the fields */
'html_after_fields' => '',
/* (string) The text displayed on the submit button */
'submit_value' => __("Add Dog", 'acf'),
/* (string) A message displayed above the form after being redirected. Can also be set to false for no message */
'updated_message' => __("Post updated", 'acf'),
/* (string) Determines where field labels are places in relation to fields. Defaults to 'top'.
Choices of 'top' (Above fields) or 'left' (Beside fields) */
'label_placement' => 'top',
/* (string) Determines where field instructions are places in relation to fields. Defaults to 'label'.
Choices of 'label' (Below labels) or 'field' (Below fields) */
'instruction_placement' => 'label',
/* (string) Determines element used to wrap a field. Defaults to 'div'
Choices of 'div', 'tr', 'td', 'ul', 'ol', 'dl' */
'field_el' => 'div',
/* (string) Whether to use the WP uploader or a basic input for image and file fields. Defaults to 'wp'
Choices of 'wp' or 'basic'. Added in v5.2.4 */
'uploader' => 'wp',
/* (boolean) Whether to include a hidden input field to capture non human form submission. Defaults to true. Added in v5.3.4 */
'honeypot' => true
);
acf_form( $options );
Is this exactly where and the order that the code appears on you page? or are you just leaving out the code in between. https://www.advancedcustomfields.com/resources/acf_form/
acf_form_head();
must be placed before any HTML is generated. Generally before get_header();
in your template or in your header.php file something like this
<?php
/**
* The template for displaying the header
*
* Displays all of the head element and everything up until the "site-content" div.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
acf_form_head();
?><!DOCTYPE html>
It may be saved in the database, but is it save to a post_id with a post type of “dog”?
I figured it out…
'new_post' => array(
'post_type' => 'dog',
'post_status' => 'published'
),
…”published” isn’t a post_status option. “publish” is…
Thanks, John! That wasn’t my issue, but I’ll move it just to be safe!
The topic ‘My acf_form is saving to the database but not showing up in the admin panel unde’ is closed to new replies.
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.