In the first shot, I have written Metabax for the management environment (wp admin, Products). In the second shot (2), I want the user to be able to fill in the field that the admin can fill in the product edit page (dokan plugin).
sshot1:
https://ibb.co/mXRJKF7
sshot2:
https://ibb.co/ZhMkrgQ
sshot3:
https://ibb.co/gWYKbFj
-
This reply was modified 4 years, 2 months ago by themefour.
How can I also display the box fields in Front End? For the user to fill in?
Hi @themefour
Trying to summarize what you’re hoping to accomplish.
You want to provide a form on the front-end for a logged in user to fill in and save the submitted items for. The content submitted should be saved as user meta for that user?
Then you want to output that content somewhere else on the site, say a profile?
@tw2113 I want the same field that appears on the product edit page to be displayed on another page (in FrontEnd) and the user fills it in!
https://ibb.co/8gbpsP5
my code for show metaboxs in product posttype:
add_action( ‘cmb2_admin_init’, ‘studiare_metaboxes’ );
function studiare_metaboxes() {
// Start with an underscore to hide fields from custom fields list
$prefix = ‘_studiare_’;
$studiare_metaboxes = new_cmb2_box( array(
‘id’ => ‘page_metabox’,
‘title’ => esc_html__( ‘Page Settings’, ‘tdomain’ ),
‘object_types’ => array( ‘page’, ‘post’ ),
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘show_names’ => true,
) );
$courses_metaboxes->add_field( array(
‘name’ => esc_html__( ‘نوع یا فرمت فایل’, ‘tdomain” ),
‘desc’ => esc_html__( ‘نوع یا فرمت فایل های محصول را وارد کنید. مثلا PSD’, ‘tdomain” ),
‘default’ => ”,
‘id’ => $prefix . ‘download_format’,
‘type’ => ‘text’,
) );
At least in terms of providing a frontend form to use, I would review the following urls:
https://github.com/CMB2/CMB2/wiki/Bringing-Metaboxes-to-the-Front-End
https://github.com/CMB2/CMB2-Snippet-Library/tree/master/front-end
Regarding display of the saved values, you would need to set up a solution that allows you to know the correct page ID that the data is saved to, and use that in conjunction with things like get_post_meta()
and the like.