Forum Replies Created
-
AuthorPosts
-
sociality
ParticipantI did that and solved it. Thanks a lot ๐
sociality
ParticipantOk,
It worked!
Thank you.
sociality
ParticipantHello Truong,
Unfortunately it does not seem to work, although I made the modification you mentioned.
Any other ideas? It seems that the metabox plugin does not retrieve the image I save.
Thank you in advance.
sociality
ParticipantOk,
You are right. Thank you. I will try it out and get back to you since there is a need.
sociality
ParticipantHello,
Yes of course.
This is the code for declaring the meta box:
/*********************************************************************** * A. ADD META BOXES FOR USERS * *********************************************************************/ function colours_meta_boxes( $meta_boxes ) { $prefix = 'andydote_'; // structure $meta_boxes[] = array( 'title' => esc_html__('Brand Info', 'andydote-eshop-plugin'), 'type' => 'user', 'fields' => array( array( 'name' => esc_html__( 'Logo', 'andydote-eshop-plugin' ), 'id' => $prefix . 'brand_image', 'type' => 'image_advanced', ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'colours_meta_boxes' );This is the code for adding the new field in "add new user" screen:
// 1b.add new form elements in user new screen function andydote_user_new_form() { ?> <h2><?php esc_html_e( 'Brand Info', 'andydote-eshop-plugin' ); ?></h2> <table class="form-table"> <tr class="form-field"> <th scope="row"><label for="andydote_brand_image"><?php esc_html_e( 'Logo', 'andydote-eshop-plugin' ) ?> </label></th> <td> <img />' height='100'> <input id="upload_brand_image_button" type="button" class="button" value="<?php esc_html_e( 'Add Media', 'andydote-eshop-plugin' ); ?>" /> <input type='hidden' name='andydote_brand_image' id='andydote_brand_image' value='<?php echo get_option( 'media_selector_attachment_id' ); ?>'> <input type="submit" name="submit_image_selector" value="Save" class="button-primary"> </td> </tr> </table> <?php } add_action( 'user_new_form', 'andydote_user_new_form' );This is the code for saving the image field:
// 3.save our extra registration user meta function andydote_user_register( $user_id ) { if ( isset( $_POST['submit_image_selector'] ) && isset( $_POST['andydote_brand_image'] ) ) { update_user_meta( 'media_selector_attachment_id', absint( $_POST['andydote_brand_image'] ) ); } } add_action( 'user_register', 'andydote_user_register' );If you are interested, I use this reference: http://jeroensormani.com/how-to-include-the-wordpress-media-selector-in-your-plugin/
Thank you!
sociality
ParticipantAlright,
Thank you.
sociality
ParticipantIt worked that too.
Thanx!
sociality
ParticipantOk, it worked!
Thank you.
I' ve got one more question. I have some select meta boxes and I want to get their name as soon as the user has selected an option and not their value.
For example, for an option such as
'past' => esc_html__( 'Past', 'colours-of-a-journey-plugin' ),I want to get the 'Past' name and not the 'past' value.
The snippet
$painting_time = rwmb_meta( 'colours_attachment_theme_tag', '', $painting['ID'] );gives me the value 'past'. How do I do that?
Thank you in advance.
sociality
ParticipantYes,
The strange thing is that it works for posts post type but not for the attachment post type. This is it:
$meta_boxes[] = array( 'title' => esc_html__( 'Artist Info', 'colours-of-a-journey-plugin' ), 'post_types' => 'attachment', 'media_modal' => true, 'fields' => array( array( 'name' => esc_html__( 'Theme tags (select one or more values)', 'colours-of-a-journey-plugin' ), 'id' => $prefix . 'attachment_theme_tags', 'type' => 'select', 'options' => array( 'past' => esc_html__( 'Past', 'colours-of-a-journey-plugin' ), 'present' => esc_html__( 'Present', 'colours-of-a-journey-plugin' ), 'future' => esc_html__( 'Future', 'colours-of-a-journey-plugin' ), 'home' => esc_html__( 'Home', 'colours-of-a-journey-plugin' ), 'nature' => esc_html__( 'Nature', 'colours-of-a-journey-plugin' ), 'passage' => esc_html__( 'Passage', 'colours-of-a-journey-plugin' ), 'peace' => esc_html__( 'Peace', 'colours-of-a-journey-plugin' ), ), 'multiple' => true, 'select_all_none' => true, ), ), );sociality
ParticipantOk thanx ๐
February 25, 2017 at 7:02 AM in reply to: โ Bug with keeping visible the fields which are already saved #5163sociality
Participantsociality
ParticipantThank you for the guidance.
It worked.
sociality
ParticipantAlright,
It worked. You can close the thread ๐
sociality
ParticipantHello,
Thank you. I installed the development version and I got some errors such as
Fatal error: Uncaught Error: Call to a member function get_source_lang_code() on null in /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-content/plugins/meta-box-master/inc/wpml.php:97 Stack trace: #0 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-includes/class-wp-hook.php(298): RWMB_WPML->modify_field(Array) #1 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array) #2 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-content/plugins/meta-box-master/inc/meta-box.php(320): apply_filters('rwmb_normalize_...', Array) #3 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-content/plugins/meta-box-master/inc/meta-box.php(46): RW_Meta_Box::normalize_fields(Array) #4 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-content/plugins/meta-box-master/inc/core.php(62): RW_Meta_Box->__construct(Array) #5 /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-includes/class-wp-hook.php(298): RWMB_Core->register_meta_boxes('') #6 /home/so in /home/socia979/public_html/coloursofajourney.eu/cOlJ/wp-content/plugins/meta-box-master/inc/wpml.php on line 97
Are you sure I can use this version for a production environment?
sociality
ParticipantHello,
Didn't quite understand.
1. Where should I put this code snippet? Inside the "fields" array?
2. For the validation to work do I have to use the development version of the plugin or did you make an update for that?Thank you.
-
AuthorPosts