Forum Replies Created
-
AuthorPosts
-
Nic
ParticipantAha! That did it! You are a wizard, thank you so much ๐
For anyone referring to this thread in the future, I had to create two separate snippets to get this to work.
First, for my main site I activated and used the exact snippet and instructions found in the tutorial here: https://metabox.io/create-custom-avatar/
Second, I used the snippet provided by Long just above and activated it on all my subsites.
Tip: If you don't have a way to manage your multisite snippets already, I used the free plugin from the WordPress repository called "snippets" because it allowed me to manage my snippets on my network site and then make them available across the network. I can choose which snippets to activate on each subsite.
So, code snippet #1 from the tutorial is active on my main network site. Snippet #2 provided by Long above is activated on all my subsites.
Nic
ParticipantYes, I cannot seem to get that to work. The example code also uses groups and settings pages which don't seem to translate for me here.
Nic
ParticipantLong,
Thank you for your helpful reply ๐ I have been trying to figure this out based on the settings page reference you gave and the tutorial here: https://metabox.io/create-custom-avatar/
I have the upload field and image working beautifully on my main site but cannot seem to get the code to work to show avatars on my subsites. This is also an issue with the MB User Avatar v1.0 plugin you offer. Do you see anything in my code below that I am doing wrong?
add_filter( 'get_avatar' , 'my_custom_avatar' , 1 , 5 ); function my_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) { switch_to_blog( 1 ); $user = false; if ( is_numeric( $id_or_email ) ) { $id = (int) $id_or_email; $user = get_user_by( 'id' , $id ); } elseif ( is_object( $id_or_email ) ) { if ( ! empty( $id_or_email->user_id ) ) { $id = (int) $id_or_email->user_id; $user = get_user_by( 'id' , $id ); } } else { $user = get_user_by( 'email', $id_or_email ); } if ( $user && is_object( $user ) ) { $value = rwmb_meta( 'custom_avatar', array( 'object_type' => 'user' ), $user->data->ID ); if ( $value ) { $avatar = "<img src='" . $value['url'] . "' class='avatar avatar-" . $size . " photo' alt='" . $alt . "' height='" . $size . "' width='" . $size . "' />"; } } return $avatar; } restore_current_blog();Nic
ParticipantHere it is:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Shifts', 'your-text-domain' ), 'id' => 'shifts', 'taxonomies' => ['shift'], 'fields' => [ [ 'name' => __( 'Start Time', 'your-text-domain' ), 'id' => $prefix . 'shift-start-time', 'type' => 'time', 'placeholder' => __( 'Military Time', 'your-text-domain' ), 'required' => true, 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Provide the time that the clinical shift starts in military time.', ], ], [ 'name' => __( 'End Time', 'your-text-domain' ), 'id' => $prefix . 'shift-end-time', 'type' => 'time', 'placeholder' => __( 'Military Time', 'your-text-domain' ), 'required' => true, 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'Provide the time that the clinical shift ends in military time.', ], ], [ 'name' => __( 'Total Hours', 'your-text-domain' ), 'id' => $prefix . 'shift_total_hours', 'type' => 'number', 'desc' => __( 'In hours and minutes are decimals. Visit <a href="https://www.engineeringtoolbox.com/minutes-decimal-hours-d_1699.html">this website for minute decimal values.</a>', 'your-text-domain' ), 'min' => 0, 'max' => 24, 'std' => 12, 'required' => true, 'tooltip' => [ 'icon' => '', 'position' => 'top', 'content' => 'How many total hours will the student be at the clinical site for this shift? To display hours and minutes use decimals. .', ], ], ], ]; return $meta_boxes; }Nic
ParticipantThank you for your answer. I feel you are correct. I have been able to cheat the system and edit some fields when I give my custom field the ID of an existing settings field, but this does not work consistently.
I will just create my own settings and find ways to incorporate that into my theme. Thank you:-)
Nic
ParticipantLarry,
I am not a Metabox developer but a customer. I have been wanting something similar for so long. However, there are limited solutions for us multisite users. While it is not ideal, the best solution I have found is the broadcast plugin. It doesn't have direct metabox.io support, but it works generally for all custom post types I have created with Metabox thanks to their awesome code.
You can see the plugin here:
Nic
ParticipantThank you for the information. I am trying to avoid the back end as it confuses my users. I love the frontend post editor because it is so simple and clean.
Is there a hook or known method to alter this behavior? Has anyone out there found a solution? I am going to try and play with some ideas but would love to know if anyone else has attempted it.
Nic
ParticipantYay! That was all I needed, to add post type, and it worked for me.
December 29, 2019 at 1:39 PM in reply to: โน๏ธMETABOXERS! Help get OxygenBuilder integration by upvoting this github issue #17664Nic
ParticipantI found this thread looking for something else and it introduced me to Oxygen... like MetaBox, I don't know how I've survived without it!
Upvote for sure!
-
AuthorPosts