Forum Replies Created
-
AuthorPosts
-
August 26, 2020 at 2:37 AM in reply to: โ Registration: username as email, duplicated fields, avatar, visibility issue #21465
Johannes Gross
ParticipantI was able to display the first_name and last_name field above the email address by using the following code:
function add_more_registration_fields($fields) { $new_fields = [ 'first_name' => [ 'name' => 'First Name', 'id' => 'first_name', 'type' => 'text', 'required' => 1 ], 'last_name' => [ 'name' => 'Last Name', 'id' => 'last_name', 'type' => 'text', 'required' => 1 ], ]; $fields = array_merge( $new_fields, $fields ); return $fields; } add_filter( 'rwmb_profile_register_fields', 'add_more_registration_fields'));Johannes Gross
ParticipantThank you Long for your reply! Switching the title and content from within the shortcode to the custom metabox did the trick. ๐
Johannes Gross
ParticipantThank you Anh!
October 18, 2019 at 7:18 PM in reply to: โ (Repeatable?) Block over certain content length crashes #16602Johannes Gross
ParticipantThank you Anh for taking care of it so quickly! Appreciate it.
Johannes Gross
ParticipantRun into it and ended up using something like following to be able to have users update their email address in the frontend:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $meta_boxes[] = [ 'title' => '', 'id' => 'edit_user_profile', 'type' => 'user', 'fields' => [ [ 'id' => 'first_name', 'name' => 'First Name', 'type' => 'text', ], [ 'id' => 'last_name', 'name' => 'Last Name', 'type' => 'text', ], [ 'id' => 'twt_user_email', 'name' => 'Email', 'type' => 'email', 'save_field' => false ], ], ]; return $meta_boxes; } ); //hide user profile metabox in backend (otherwise duplicate) add_filter( 'rwmb_show_edit_user_profile', '__return_false' ); //populate twt_user_email add_filter('rwmb_twt_user_email_field_meta', function($meta, $field, $saved) { $user = wp_get_current_user(); return $user->user_email; }, 10, 3); //update users email upon profile update add_filter('rwmb_profile_update_user_data', function($data, $config ) { $data['user_email'] = sanitize_email($_POST['twt_user_email']); return $data; }, 10, 2);Johannes Gross
ParticipantAgain, thanks for fixing the Image Advanced field. This is now working great.
However, today I noticed that in a cloneable group block, the order does not save (e.g. changes back when reloading).Here is the code I am using:
add_action('rwmb_meta_boxes', 'twt_metabox_io_blocks'); function twt_metabox_io_blocks($meta_boxes) { $meta_boxes[] = array( 'id' => 'twt-people-block', 'title' => 'TWT People Block', 'type' => 'block', 'icon' => 'admin-users', 'category' => 'formatting', 'context' => 'side', 'render_callback' => 'render_twt_people_block', 'supports' => array( 'anchor' => true, 'customClassName' => true, ), 'fields' => array( array( 'name' => '', 'id' => 'people', 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => array( array( 'name' => 'Photo', 'desc' => 'Ideal size: 200px x 200px', 'id' => 'image', 'type' => 'single_image', ), array( 'name' => 'Caption (e.g. Person\'s Name)', 'id' => 'caption', 'type' => 'textarea', 'rows' => 2 ), ) ) ) ); return $meta_boxes; } function render_twt_people_block($attr, $is_preview = false, $post_id = null) { if ( empty( $attr['data'] ) ) { return; } // Unique HTML ID if available. $id = 'twt_people-' . ( $attr['id'] ?? '' ); if ( ! empty( $attr['anchor'] ) ) { $id = $attr['anchor']; } // Custom CSS class name. $class = $attr['className'] ?? ''; if ( ! empty( $attr['align'] ) ) { $class .= " align{$attr['align']}"; } if(isset($attr['data']['people'])) { ?> "> <?php } ?> </div> </div> <?php } }I know the caption field is kind of redundant... ๐
Thanks for checking into it...
Johannes Gross
ParticipantThank you!
Johannes Gross
ParticipantGreat! Thank you for your reply and for staying on top of this!
-
AuthorPosts