load post_status into select field

Support MB Frontend Submission load post_status into select fieldResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #47050
    Nicholas CoxNicholas Cox
    Participant

    Hi

    is it possible when editing a post using the front end shortcode submission to auto populate the following field?

    [
    	'type'  => 'select',
    	'name'  => 'Status',
    	'id'    => 'post_status',
    	'options' => [
    		'publish' => 'Published',
    		'draft'  => 'Draft',
    	],
    	'multiple' => false,
    	'placeholder' => "",
    	'select_all_none' => false,
    	'required' => true,
    ],
    #47058
    PeterPeter
    Moderator

    Hello Nick,

    You can use a form hook like rwmb_frontend_after_save_post or the action hook rwmb_{$field_id}_after_save_field to update the post status based on the custom field value. Here is an example https://support.metabox.io/topic/controlling-post-status-in-front-end-dashboard/#post-31734

    Following the documentation https://docs.metabox.io/extensions/mb-frontend-submission/#post-actions
    https://docs.metabox.io/actions/rwmb-after-save-field/

    #47075
    Nicholas CoxNicholas Cox
    Participant

    Hi, ok but the 'rwmb_{$field_id}_after_save_field' is ok for saving the field for the post_status, but i am looking to auto populate the form when editing a post. Does metabox automatically populate a field with the id of post_status with the post status value e.g. draft?

    I ask as if you are editing a draft post using the front end form then i need it to recognise the current post_status and auto select this from the select field.

    thanks

    #47084
    PeterPeter
    Moderator

    Hello,

    There are two cases:

    1. Before using the action hook "rwmb_{$field_id}_after_save_field", it won't auto-populate field value by the post status.

    2. After using the action hook "rwmb_{$field_id}_after_save_field" to update the post status based on the field value, it will show the field value normally (auto-populate) after saving the post.

    #47206
    Nicholas CoxNicholas Cox
    Participant

    ok well i thought you supported the post_status field like you do for the post title etc.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.