Skip Navigation

[Resolved] Custom Post Status not selectable in CRED post edit form

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by hannahM 6 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#604720

Hi there,

I have a CRED form on echoesanddust.com which authors use to submit content. When it creates a post it creates it with the 'Pending Review' status.

I'm currently in the process of creating a second CRED form which editors can use to edit content ready for publication. I have created a new post status of 'Reviewed' and I would like posts to be changed to this status when an editor makes and submits their changes, so the post can then be published by the editor in chief.

However in the "Status of content created or edited by this form:" dropdown area on the edit form, my newly created post status does not appear. Is there a way I can make this new status display in the dropdown here?

This is the php function I've used to create the status:

if ( ! function_exists('custom_post_status') ) {

// Register Custom Status
function custom_post_status() {

$args = array(
'label' => _x( 'Reviewed', 'Status General Name', 'text_domain' ),
'label_count' => _n_noop( 'Reviewed (%s)', 'Reviewed (%s)', 'text_domain' ),
'public' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'exclude_from_search' => false,
);
register_post_status( 'reviewed', $args );

}
add_action( 'init', 'custom_post_status', 0 );

}

Thanks!

Hannah

#604886

Toolset plugins don't fully support custom post statuses, mostly because the register_post_status function in WordPress isn't fully implemented. See the documentation here:
https://codex.wordpress.org/Function_Reference/register_post_status

Once this function is fully implemented, Toolset will be able to support these statuses more effectively. One way you could get around this is to set the post status to Draft in your CRED form, then use the cred_save_data API to modify the post status after submission. Something like this:

add_action('cred_save_data', 'cred_custom_status_action',10,2);
function cred_custom_status_action($post_id, $form_data)
{
    // Change the status of the post just created by CRED
    if ($form_data['id']==12345) {
         $my_post = array(
            'ID'           => $post_id,
            'post_status'   => 'reviewed'
        );

        // Update the post in the database
        wp_update_post( $my_post );
    }
}

Replace 12345 with your form ID.

#605208

Hi Christian,

Many thanks for the reply, that makes sense. I'll try this fix, thanks!

Just as an additional question, if I found a method (or a plugin) which registered custom post types in a way which also added them to the drop-down list in the WordPress post edit screen, would that also result in them being added to the dropdown in the CRED form? Or would further work still be needed in that instance?

Cheers!

Hannah

#605236

CRED should be able to recognize publicly registered post types from other plugins. If the post type is not public, it will not work. I'm not sure what you mean by "...which registered custom post types in a way which also added them to the drop-down list in the WordPress post edit screen", but as long as it's a public post type you should be okay.

#605688

Hi Christian,

Sorry, I could have been clearer there. As I understand it, you're saying the CRED plugin doesn't display custom post-statuses on its drop-down because WordPress hasn't fully implemented that functionality yet - which is also why my newly created custom status doesn't appear in the dropdown in the WordPress post edit screen.

My question is this: There are a few plugins which offer the functionality to add custom post statuses rather than registering them myself with the php snippet. If any of those plugins also include the functionality to display the custom status in the WordPress post edit screen dropdown, will it also automatically display in the CRED form edit screen dropdown? Or does it fetch & display post statuses in a different way?

In any event, I think your answer has answered my question, thanks! 🙂

Hannah