Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi,
rwmb_meta( 'image_field_id' )returns an array of image info. To get the URL of the image, simply use the code like this:$image_info = rwmb_meta( 'image_field_id', 'size=thumbnail' ); echo $image_info['url']; // Thumbnail size URL echo $image_info['full_url']; // Full size URLAnh Tran
KeymasterCan you please try download again? I think I uploaded the wrong file.
Anh Tran
KeymasterHi,
We probably haven't supported it yet. The
user_roleactually is the role for being edited users. It's not for the current user, who is editing. We'll update the extension to add more condition for the current user.Anh Tran
KeymasterHi,
Just realized that you asked about a field, not a meta box. The include / exclude extension works for meta boxes only, not for fields.
So, in this situation, you probably need to use PHP code to check and register a field for a meta box. Something like:
$fields = array(); // Define all your fields here if ( current_user_can( 'manage_options' ) ) { $fields[] = array( 'type' => 'text', 'name' => 'Custom field for admin only', 'id' => 'admin_only', ); } // Register meta box $meta_boxes[] = array( 'type' => 'user', 'title' => 'Profile fields', 'fields' => $fields, );Anh Tran
KeymasterThe
user_roleis the role of the being edited users, not the current users. In this case, if you want to editeditorusers, you need to set'user_role' => 'editor'.Anh Tran
KeymasterYou can get file info with the helper function
RWMB_File_Field::file_info( $file ), like this:$group = rwmb_meta('media'); foreach($group as $data){ $files = rwmb_meta($data['mb_file']); foreach($files as $file) { $file_data = RWMB_File_Field::file_info( $file ); var_dump( $file_data ); } }June 22, 2017 at 12:58 PM in reply to: "Oops something went wrong" in Address field on example.php meta box #6145Anh Tran
KeymasterDear Jason,
As you can see, it says Undefined index: badgeos in /home/40951-69099.cloudwaysapps.com/czfybpbunb/public_html/wp-content/themes/obodohub-cts-master-0.5.2/functions.php on line 438.
Can you please fix that warning?
Cheers!
Anh Tran
KeymasterHello,
Do you want to get list of custom post types or list of posts of some custom post types?
In 1st case, you can use the function get_post_types() to get all the post types:
$options = array(); $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ); foreach ( $post_types as $post_type ) { $options[$post_type->slug] = $post_type->name; }And in the select, just set
'options' => $options.In the 2nd case, you can use the field type
postand set'post_type' => 'your_post_type', and all the posts will be populated in the select option. For more info, please check this guide.June 21, 2017 at 5:01 PM in reply to: Clonable fields within clonable fields are not working with certain fields #6137Anh Tran
KeymasterJust updated the plugin with the fix you provided :).
Thanks for your contribution.
Anh Tran
KeymasterDear bdthemes,
Here is an example:
add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' ); function YOURPREFIX_register_meta_boxes( $meta_boxes ) { // Define a meta box $meta_box = array( 'title' => __( 'Media', 'textdomain' ), 'post_types' => 'post', 'fields' => array( array( 'name' => __( 'URL', 'textdomain' ), 'id' => 'url', 'type' => 'text', ), ) ); // Add new field when condition meets if (get_theme_mod( 'orphan_toolbar')) { $meta_box['fields'][] = array( 'name' => 'Toolbar', 'id' => $prefix . "toolbar", 'type' => 'checkbox', 'desc' => 'Enable or disable the toolbar for this page.', 'tab' => 'layout', ), } // Add the meta box to $meta_boxes array to register $meta_boxes[] = $meta_box; }Anh Tran
KeymasterDear woorie,
Because toggle_type is affected to whole field/meta box and its container and many fields aren't normal form input field so it isn't possible. Sorry for that.
June 21, 2017 at 8:57 AM in reply to: "Oops something went wrong" in Address field on example.php meta box #6115Anh Tran
KeymasterDear Jason,
Can you please tell me your PHP version, in the example I use anonymous function so perhaps it doesn't works with PHP 5.2.
Btw, can you please turn on WP_DEBUG and/or WP_DEBUG_LOG to see the full output message. Kindly check the WP official documentation: https://codex.wordpress.org/Debugging_in_WordPress
Best regards,
TanAnh Tran
KeymasterDear woorise,
The plugin is intended to show or hide field or meta box, it cannot disable a field.
Best,
Tan
Anh Tran
KeymasterDear bdthemes,
Conditional Logic works with Javascript callback only, it doesn't works with PHP, however, with PHP, you can check if meet a condition and then register meta box or field, like so:
if (get_theme_mod('orphan_toolbar')) { $meta_boxes = [ ... ]; }Anh Tran
KeymasterDear kotofey,
1. Yes, I'll add it to the next minor release this month.
2. Yes, I have already written a guide for you.
https://metabox.io/docs/hide-meta-box-tabs-conditional-logic/ -
AuthorPosts