Support MB Frontend Submission How to include current post title on a form Reply To: How to include current post title on a form

#10167
davidrknowlesdavidrknowles
Participant

I tried this and I thought get_the_title(get_the_ID()) might work as an std but it doesn't, mainly I think due to when the filter fires.

But I think what might work is using one of the hooks, try this:

add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
    if ( 'my-meta-box' === $config['id'] ) {
        $sub_title = get_the_title(get_the_ID());
        update_post_meta($post_id, 'submitted_from',  $sub_title);
    }
}, 10, 2 );

Change "my-meta-box" to your overall meta_box id,
change "submitted_from" to the field you want to populate.

If you don't want this field to show on the front end you may have to manually hide it.

Hope this helps you.