Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterOoops, so strange. This is my personal Gmail. Maybe Gmail doesn’t accept files with some executable code (in JavaScript). Please try resending to another Yahoo email [email protected] or share it with me on Google Drive / Dropbox.
August 21, 2017 at 9:23 AM in reply to: ✅Suggesting a Logic and Validation for Multiple checbox #6710Anh Tran
KeymasterHi,
I see your code to register meta boxes has no problem. Do you want to optimize the code to get the values (and show them) in the frontend? By reducing the number of IF checks?
Anh Tran
KeymasterHi,
Glad that you asked these questions. Please find my answers below:
1. do i need to copy the code genereated by MB Custom Post Type for each CPT and put it in functions.php?
No. The plugin does all the work for you.
2. do i need to follow the steps in this page: https://metabox.io/docs/registering-meta-boxes/ (copy the code to register meta-box) even though i have MB Builder / MB Custom Post Types installed?
No. That are the purpose of the extensions, e.g. without touching code. You don't need to copy the code.
3. also- the code in that page start with the line:
add_filter( ‘rwmb_meta_boxes’, ‘YOURPREFIX_register_meta_boxes’ );
this line is missing from the code generated by MB Custom Post Types (as mentioned in question 1). is this ok or should i add that line?No. As you already used MB Builder extension, you don't need to copy the code.
4. should i copy-paste any code to register my custom taxonimies and custom fields?
No. The MB Custom Post Types already did that for you.
5. in the tutorial for “Get custom field value and display in the front end” (this page: https://metabox.io/docs/get-meta-value/) you say: “To get field meta value, use this function:” and show some code – but it’s unclear where to put this code?
You should find the template files of your theme and paste the code there. Each theme has several PHP template files. You just need to find which file displays your pages, open it and paste the code in that file. To understand about template files of a WordPress theme, please read this documentation.
6. in that same page you say: “To display field value in the frontend, just put the code below in your theme’s template file:” and show some PHP code – but – my template using .yaml files, not .php files.
I'm not sure why your theme uses .yaml files. Can you please tell us about your system? Maybe you use a very different system that overwrite WordPress template system.
Again, to understand about WordPress themes and template files, please read these pages:
https://codex.wordpress.org/Stepping_Into_Templates
https://developer.wordpress.org/themes/basics/template-files/Anh Tran
KeymasterOops, how bad Google Apps is. Please resend to [email protected]. Thanks.
Anh Tran
KeymasterAh, I got it!
Looks like we don't have such a solution for this in PHP yet. The best solution for now is using Conditional Logic extension to hide the fields from unwanted users. But it only hides from user and the fields are still outputted.
Anh Tran
KeymasterHi fez, sorry to see you go. I've just issued the refund. If you change your mind, we're happy to serve you.
Best regards
AnhAnh Tran
KeymasterHi,
Thanks a lot for your contribution. Can you please send me your code via email [email protected]? We're hosting the extensions in private repositories, so no pull requests are allowed now.
Anh Tran
KeymasterJust released new version for the extension. Please update.
Anh Tran
KeymasterHi,
Can you give some details on the 1st option? Do you use the MB Frontend Submission extension to output fields in the frontend? I'm not very clear about the downside.
Anh Tran
KeymasterIf you need to make for groups, you can set
stdas array of arrays of default values for sub fields, like:$default_for_group = array( '', '', '' ); // sub field 1, 2, 3 'std' => array( $default_for_group, $default_for_group, $default_for_group ),To prevent users from removing clones, you can hide them with CSS. A simple trick is adding a custom_html field to output styles, like this:
array( 'type' => 'custom_html', 'std' => '<style>.rwmb-group-wrapper .remove-clone { display: none; }</style> )You might want to add custom class to your group fields, so the CSS selector is more specific.
Anh Tran
KeymasterThanks for letting us know. We'll fix it soon.
Anh Tran
KeymasterHi,
This problem is caused by the validation library. It checks by the ID attribute. When cloning, we change the ID (by appending _1, _2, etc.) and thus, break the validation. We'll try to find a solution soon.
Anh Tran
KeymasterHi,
Yes, you can do that by specified the
stdvalue. This code will set the 3 inputs (clones):array( 'type' => 'text', 'id' => 'test', 'clone' => true, 'max_clone' => 3, 'std' => array( '', '', '' ) // Default values for 3 clones )Anh Tran
KeymasterHi zac, I've just fixed the bug with checkbox list. Please update the extension.
Anh Tran
KeymasterThank Troels for the bug and fix. We'll fix it now 🙂
Update: New version is available. Please update.
-
AuthorPosts