You need to check the upload_files
capability.
you need to remove this code:
'html_before_fields' => '<input type="text" name="post_title" size="30" id="title" placeholder="Enter title here" autocomplete="off">',
you need to create a text custom field that you will assign to be your title. The code below assigns the custom field to be the post title:
$post = array(
'ID' => $post_id,
'post_type' => 'events',
'post_title' => $fields['new_title']['value'],
'post_status' => 'draft'
);
please also include this code inside the function before the // Continue save action
. I completely forgot about it:
// Update the Post
wp_update_post( $post );
edited my post above as well and added this code.
You need to use ACF’s acf/save_post
action hooks for this. I have seen this code somewhere here in the forum, but can’t find the link to that, so I’m pasting it below:
function ps_acf_save_post( $post_id ) {
// Don't do this on the ACF post type
if ( get_post_type( $post_id ) == 'acf' ) return;
// Get the Fields
$fields = get_field_objects( $post_id );
// Prevent Infinite Looping...
remove_action( 'acf/save_post', 'my_acf_save_post' );
// Grab Post Data from the Form
$post = array(
'ID' => $post_id,
'post_type' => 'post',
'post_title' => $fields['new_title']['value'],
'post_content' => $fields['new_description']['value'],
'post_status' => 'publish'
);
// Update the Post
wp_update_post( $post );
// Continue save action
add_action( 'acf/save_post', 'my_save_post' );
// Set the Return URL in Case of 'new' Post
$_POST['return'] = add_query_arg( 'updated', 'true', get_permalink( $post_id ) );
}
add_action( 'acf/save_post', 'ps_acf_save_post', 10, 1 );
new_title is a my custom field to be replicated for the Title and new_description for the content.
I also had a similar issue, but the only way to do this is to edit the WordPress role. You can do that via the User Role Editor plugin or a similar one. Just tick the upload_files capabilities for subscriber.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.