I removed some code from functions file. It's saving now.
Is it possible to set the default Post Status from current status rather than default to Publish?
And is it possible to check for duplicates on the slug when saving?
Post Status (defaults to Publish every time),
=> OK, I've added following shortcode to get post status of partner:
add_shortcode( "get_partner_status","func_get_partner_status");
function func_get_partner_status($atts){
return get_post_field( 'post_status', $_GET['partner_id']);
}
Now, the field looks like this - where we used [get_partner_status] to assign default status as well as we used attribute "persist":1, so that the field value will be saved automatically.
Thanks you, Minesh. Post status is defaulting correctly now.
For post author, on 1st load of the edit form, it defaults to 'not set', which is fine.
After we assign the author, save changes and reload the form, it still defaults to 'not set' even though the author has actually changed.
Yes, slug is working except for the initial form load. But this isn't a big issue for us since it does default after the first save. I suspect maybe its due to the post being in draft mode, but I'm not sure.
Well - it was not working because the right post field key was not assigned to the following code:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==1647)
{
$my_post = array(
'ID' => $post_id,
'post_author' => $_POST['post_author']
);
// Update the post into the database
wp_update_post( $my_post );
}
}
=> hidden link
I've adjusted the code as above and I can see its working fine. Can you please confirm.