Forum Replies Created
-
AuthorPosts
-
January 21, 2021 at 10:40 AM in reply to: ✅Image Advanced field "Force delete" option doesn't work #24110
Long Nguyen
ModeratorHi,
I also use the MB Builder on the screen record. The documentation also notes about this setting:
force_deleteWhether or not delete the images from Media Library when deleting them from post meta.trueorfalse(default).Delete the image from the list of the field which is created by Meta Box - post meta, not delete the image when deleting the post.
January 21, 2021 at 10:36 AM in reply to: ✅front end submission dashboard with custom post type #24109Long Nguyen
ModeratorHi,
Please share the admin site account via this contact form https://metabox.io/contact/. I will check the Frontend Dashboard on your site.
January 20, 2021 at 11:17 PM in reply to: ✅front end submission dashboard with custom post type #24104Long Nguyen
ModeratorHi Radoslaw,
Please share some screenshots (full screen) when editing the page (frontend submit and frontend dashboard) and shortcodes that you are using. I've tested the frontend dashboard with two post types but not see any issue.
January 20, 2021 at 6:02 PM in reply to: ✅Image Advanced field "Force delete" option doesn't work #24101Long Nguyen
ModeratorHi,
The option
'force_delete' => trueis to delete the media file when removing it from the post meta (list images of image_advanced field). See my screen record for more information https://share.getcloudapp.com/v1u4Z8BD.Long Nguyen
ModeratorHi,
At first, please follow this documentation to know how to use AJAX in WordPress https://codex.wordpress.org/AJAX_in_Plugins, then you can use this sample code to show the term meta on selecting the field taxonomy.
add_action( 'admin_footer', function() { ?> <script> jQuery(document).ready(function($) { $('.rwmb-field').on('change', function() { var that = $(this); // Get the term ID on select var term_id = that.find('select[name=post_meta_taxonomy').val(); // Create a div to show the response that.append('<div id="meta-taxonomy-response"></div>'); var data = { 'action': 'my_action', 'term_id': term_id, }; jQuery.post(ajaxurl, data, function(response) { $('#meta-taxonomy-response').html(response); }); }) }); </script> <?php } ); add_action( 'wp_ajax_my_action', 'my_action' ); function my_action() { $term_id = $_POST['term_id']; if( isset( $term_id ) ) { $term_meta = rwmb_meta( 'category_meta_text', array( 'object_type' => 'term' ), $term_id ); echo '<h4 style="color: red">Category Meta Text: ' . $term_meta. '</h4>'; } else { echo "Not found"; } wp_die(); // this is required to terminate immediately and return a proper response }Screen record https://share.getcloudapp.com/5zudxE49.
Long Nguyen
ModeratorYou can also use the AJAX in WordPress to get the term meta right after select the term. Example in this artilce.
Long Nguyen
ModeratorHi,
I think you can use the filter rwmb_{$field_id}_end_html to use the field value and add some HTML code after the field appearance. For simple example, I have the custom field
post_meta_taxonomytype taxonomy for the post and a custom fieldcategory_meta_textfor the taxonomy Category. The code below would help you to show the term meta base on the term ID selected.add_filter( 'rwmb_post_meta_taxonomy_end_html', function( $end, $field, $meta ) { $term_meta = rwmb_meta( 'category_meta_text', array( 'object_type' => 'term' ), $meta ); if( !empty( $term_meta ) ) { $end .= '<h4 style="color: red">Category Meta Text: ' . $term_meta. '</h4>'; } return $end; }, 10, 3 );See a short screen record https://share.getcloudapp.com/YEuQxzny.
Long Nguyen
ModeratorHi,
If you are using the extension MB Frontend Submission to submit a post from the frontend, you can use the action hook rwmb_frontend_after_process to update the current post ID to the field value.
The code would be:
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { if ( 'confirmation-lecture' === $config['id'] ) { update_post_meta( $post_id, 'testtest', get_queried_object_id() ); } }, 10, 2 );$post_idis the ID of the post that will be created.
get_queried_object_id() is the function which returns the current post ID (the post that shows the form submit).Long Nguyen
ModeratorHi,
Thank you for your reporting.
The sanitization is used for the regular cases, for a specific case, you can bypass the sanitization by using the setting
'sanitize_callback' => 'none'. Get more details in the documentation https://docs.metabox.io/sanitization/#bypass-the-sanitization.Long Nguyen
ModeratorHi,
Please see my screen record https://share.getcloudapp.com/DOuopnDR. The code works as well on my local site. If it still does not work, please share the admin site account via this contact form, I will check it out.
Long Nguyen
ModeratorHi,
Have you tried the code that I post above?
function confirmation_lecture_register_meta_boxes( $meta_boxes ) { $prefix = ''; // Get the $post_id here $post_id = null; if ( isset( $_GET['post'] ) ) { $post_id = intval( $_GET['post'] ); } elseif ( isset( $_POST['post_ID'] ) ) { $post_id = intval( $_POST['post_ID'] ); } $meta_boxes[] = [ 'title' => esc_html__( 'Confirmation de lecture', 'text-domain' ), 'id' => 'confirmation-lecture', 'fields' => [ [ 'id' => $prefix . 'testtest', 'type' => 'text', 'attributes' => array( 'value' => $post_id, // Here is the value who's not working ) ] ], ]; return $meta_boxes; }Long Nguyen
ModeratorHi,
Get and echo the post ID on the front end - template of the plugin xxxxxx.com/docs/doc-1/ - is different from the backend when registering the meta box and custom fields.
Could you please share some screenshots (full screen) and the code that creates the meta box, custom fields where the post ID is not retrieved?
Long Nguyen
ModeratorHi,
I've tested the Google Map field with my API key on your site but not see any issue, screen record https://share.getcloudapp.com/DOuoOJ7P.
Long Nguyen
ModeratorHi,
To include the header in the view, you can just use the WP function get_header()
{{ mb.get_header() }} HERE WILL DISPLAY THE VIEWsee more on this documentation https://developer.wordpress.org/themes/basics/template-files/#using-template-files.
or add the
<head>tag to show only the<head><head> <meta charset="{{mb.bloginfo( 'charset' )}}"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link rel="profile" href="http://gmpg.org/xfn/11"> {{ mb.wp_head() }} </head> <body> HERE WILL DISPLAY THE VIEW </body>Long Nguyen
ModeratorHi,
Please share your admin site account via this contact form https://metabox.io/contact/. I will check it out.
-
AuthorPosts