Forum Replies Created
-
AuthorPosts
-
Yasmine
ParticipantHi just to clarify, I am adding this into an elementor text editor. If I write
[rwmb_meta id="academicyear"]Then it works! But if I write:
[rwmb_meta id="academicyear" object_type="term"]Then it does not work. This is a taxonomy. Am I using the right object type?
All the rest do not work if I do or do not use object_type. The only one working is year. And all the IDs are correct.
Yasmine
ParticipantThank you Long!
And sorry for being a newbie, but I added the 'commit' to my php files and changed the orderby to just 'title' in the relationship query_args. But it didn't work. Did I do what you suggested correctly?
Yasmine
ParticipantTHANK YOU - it works! I can use this for every other relationship i'll need to reference.
Yasmine
ParticipantShould it be something more like:
add_shortcode( 'show_user_post_related', function() { $author_id = get_post_field( 'post_author', get_queried_object_id() ); $post_id = rwmb_meta( 'university_group', ['object_type' => 'university'], $author_id ); //university_group is my name of custom field group, object_type is my name of cpt if ( empty( $post_id ) ) { return ''; } $output = get_the_title( $post_id ); return $output; } );The field within the university I want to fetch is also the
post_titleYasmine
ParticipantSorry, no the authors are not the author of the university post, this is just associated with them. So this does not work. I am trying to display this information within a different custom post type (research). And a specific field within the university post (university_Name). Please can you tell me how to adapt my shortcode so it works!
Yasmine
ParticipantHi Anh,
Thank you for the reply - it is the user profile I am using. And then I wish to show the user info on an about the author section in a post.
Here is the short code:
[mb_user_profile_info id= "academic_profile, university_2_user_relationships_from"
label_submit="Continue" confirmation="Academic details were updated"]Yasmine
ParticipantOk - I will make the frontend
relationshipwork, and will redesign the form - maybe break down into three meta groups. I think you're right and its the easiest thing to do.Which means, I would just need to output the user
from relationship. I tried the shortcode in the documentation, but it wasn't working for me (triedtoandfromdirections to be sure).So Im now trying to add my own shortcode:
add_shortcode( 'show_user_post_related', function() { $author_id = get_post_field( 'post_author', get_queried_object_id() ); $post_id = rwmb_meta( 'university_2_user_relationships_from', ['object_type' => 'user'], $author_id ); if ( empty( $post_id ) ) { // where am I going wrong here? return ''; } $output = get_the_title( $post_id ); return $output; } );But what have I done wrong? If I can fix this shortcode, then I will (finally) give up on the auto-populating idea!
Yasmine
ParticipantIs there any way to do with
Image Uploadinstead? It is nicer for the user to just select, and not have to use WP's media upload.. Or is there a way to makesingle_uploadfunction without going using the WP media ?Yasmine
ParticipantHi Long,
I am really sorry but I do not understand what you mean. Do you mean make it like this:
add_action( 'rwmb_profile_after_save_user', function( $config, $user_id ) { if ( 'academic_profile' === $config['id'] ) { $related_post_ids = empty( $_POST['university'] ) ? (array) $_post['academics_university'] : []; foreach ( $related_post_ids as $related_post ) { MB_Relationships_API::add( $user_id, $related_post_id, 'university_to_user' ); } } }, 10, 2 );I would be happy to use the normal
relationshipfield if it could be ordered within the frontend form - but instead it stands alone- I made a Loom to show you. So I want to use thepostfields UX as a workaround to select a post, which value also equals a relationship - so it can be hidden from the frontend formYasmine
ParticipantOk so do you mean do this instead:
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { if ( 'academic_profile' === $config['id'] ) { // now field group ID $related_post_ids = empty( $_POST['university'] ) ? (array) $_post['academics_university'] : []; foreach ( $related_post_ids as $related_post ) { MB_Relationships_API::add( $post_id, $related_post_id, 'university_to_user' ); } } }, 10, 2 );Yasmine
ParticipantThis is the user frontend:
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Profile', 'your-text-domain' ), 'id' => 'academic_profile', 'type' => 'user', 'tabs' => [ 'basic_info_tab' => [ 'label' => 'Basic Info', 'icon' => 'dashicons-admin-users', ], 'academic_profile' => [ 'label' => 'Academic Profile', 'icon' => 'dashicons-welcome-learn-more', ], 'social_sharing' => [ 'label' => 'Social Sharing', 'icon' => 'dashicons-share1', ], ], 'fields' => [ [ 'name' => __( 'Academic Title', 'your-text-domain' ), 'id' => $prefix . 'academic_title', 'type' => 'select_advanced', 'options' => [ 'Dr' => __( 'Dr', 'your-text-domain' ), 'Professor' => __( 'Professor', 'your-text-domain' ), ], 'columns' => 3, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'First Name', 'your-text-domain' ), 'id' => $prefix . 'first_name', 'type' => 'text', 'columns' => 4, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'Last Name', 'your-text-domain' ), 'id' => $prefix . 'last_name', 'type' => 'text', 'columns' => 5, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'Pronouns', 'your-text-domain' ), 'id' => $prefix . 'user_pronouns', 'type' => 'text', 'datalist' => [ 'id' => '62583f61cc701', 'options' => [ 'He/Him ', 'She/Her ', 'They/Them', ], ], 'tab' => 'basic_info_tab', ], [ 'name' => __( 'Nationality', 'your-text-domain' ), 'id' => $prefix . 'user_nationality', 'type' => 'select_advanced', 'options' => [ //deleted options to make shorter ], 'multiple' => true, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'Biography', 'your-text-domain' ), 'id' => $prefix . 'description', 'type' => 'textarea', 'desc' => __( '1-2 sentences', 'your-text-domain' ), 'tooltip' => [ 'icon' => 'info', 'position' => 'top', 'content' => 'Write a sentence to introduce yourself. Keep it as short as a tweet - 280 characters.', ], 'limit' => 280, 'textarea_rows' => 4, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'Profile Picture', 'your-text-domain' ), 'id' => $prefix . 'custom_avatar', 'type' => 'single_image', 'force_delete' => true, 'tab' => 'basic_info_tab', ], [ 'name' => __( 'University', 'your-text-domain' ), 'id' => $prefix . 'academics_university', /*this is the field that I am trying to duplicate into the relationship*/ 'type' => 'post', 'post_type' => ['university'], 'field_type' => 'select_advanced', 'tab' => 'academic_profile', ], [ 'name' => __( 'Faculty', 'your-text-domain' ), 'id' => $prefix . 'faculty', 'type' => 'select_advanced', 'options' => [ = //deleted options to make shorter ], 'columns' => 6, 'tab' => 'academic_profile', ], [ 'name' => __( 'Academic Position', 'your-text-domain' ), 'id' => $prefix . 'academic_position', 'type' => 'select_advanced', 'options' => [ //deleted options to make shorter ], 'columns' => 6, 'tab' => 'academic_profile', ], [ 'name' => __( 'University Profile Page', 'your-text-domain' ), 'id' => $prefix . 'university_profile', 'type' => 'url', 'tab' => 'social_sharing', ], [ 'name' => __( 'Linkedin Link', 'your-text-domain' ), 'id' => $prefix . 'linkedin', 'type' => 'url', 'tab' => 'social_sharing', ], [ 'name' => __( 'Twitter Handle', 'your-text-domain' ), 'id' => $prefix . 'twitter', 'type' => 'text', 'prepend' => '@', 'attributes' => [ 'pattern' => '[^()/><\\][\\\\\\x22,;|]+', ], 'tab' => 'social_sharing', ], [ 'name' => __( 'Orchid Profile', 'your-text-domain' ), 'id' => $prefix . 'orchid', 'type' => 'url', 'tab' => 'social_sharing', ], [ 'name' => __( 'Email', 'your-text-domain' ), 'id' => $prefix . 'user_email', 'type' => 'email', 'tab' => 'social_sharing', ], [ 'name' => __( 'Email Sharing', 'your-text-domain' ), 'id' => $prefix . 'email_sharing', 'type' => 'checkbox', 'label_description' => __( 'Include your email on your profile so members can get in touch', 'your-text-domain' ), 'std' => true, 'tab' => 'social_sharing', ], ], ]; return $meta_boxes; }'University => User relationship:
<?php add_action( 'mb_relationships_init', 'your_prefix_function_name' ); function your_prefix_function_name() { MB_Relationships_API::register( [ 'id' => 'university_to_user', 'from' => 'university', 'to' => [ 'object_type' => 'user', 'post_type' => 'post', 'taxonomy' => 'category', ], ] ); }Does this help at all?
Yasmine
ParticipantThank you - so there is no way I can do it now? Or is there a workaround?
It just doesn't look so nice for the user
April 13, 2022 at 11:34 PM in reply to: ✅Migrating taxonomy from taxonomy_advanced to taxonomy #35621Yasmine
ParticipantI spent the whole of yesterday manually migrating, and so pleased there wasn't an instant way that I missed. But the service request would have been great - Great to know that exists for next time!
Yasmine
ParticipantGreat - so that means I just need to reference every post to get every value?
Yasmine
ParticipantHi Long - just wanting to follow up on this, before I migrate all my fieldset over to a group..
-
AuthorPosts