Forum Replies Created
-
AuthorPosts
-
February 17, 2023 at 8:49 PM in reply to: ✅Passing a variable value to a hidden field in Frontend Form Submission #40575
Fernando Arbex
ParticipantVery good to see there's a solution.
I tried out myself but when I used the shortcode, it only displayed the title.Here´s the shortcode I used on Gutenberg.
[mb_frontend_form id="vendas" post_fields="title" label_title="Nome do cliente" submit_button="Cadastrar venda" edit="false" allow_delete="false" post_status="publish" redirect="" confirmation="Cadastro feito com sucesso"]What could be?
May 23, 2022 at 9:36 PM in reply to: ✅User Display Name instead of ID in MB Frontend Submission #36154Fernando Arbex
ParticipantHi Long,
Just figure out the issue, here's the code:
<?php add_action( 'rwmb_celulas_after_save_post', 'update_post_title'); function update_post_title( $post_id ) { // Get user display name $user = wp_get_current_user(); $displayName = $user->display_name; // $displayName = rwmb_the_value( 'my_field_id', ['link' => false] ); $post_slug = sanitize_title_with_dashes ($my_post,'','save'); $post_slugsan = sanitize_title($post_slug); // Prepare update post $my_post = array( 'ID' => $post_id, 'post_title' => $displayName, 'post_name' => $post_slugsan, ); wp_update_post( $my_post ); }I really appreciate your help and effort.
May 23, 2022 at 8:48 PM in reply to: ✅User Display Name instead of ID in MB Frontend Submission #36151Fernando Arbex
ParticipantHi long, thank you for the answer.
You are very helpful.I believe I'm getting close, but for some reason the title is blank.
Here is the code:
<?php add_action( 'rwmb_celulas_after_save_post', 'update_post_title'); function update_post_title( $post_id ) { // Get user display name $user_id = rwmb_meta( 'post_title' ); $user = get_userdata( $user_id ); $displayName = $user->display_name; // $displayName = rwmb_the_value( 'my_field_id', ['link' => false] ); $post_slug = sanitize_title_with_dashes ($my_post,'','save'); $post_slugsan = sanitize_title($post_slug); // Prepare update post $my_post = array( 'ID' => $post_id, 'post_title' => $displayName, 'post_name' => $post_slugsan, ); wp_update_post( $my_post ); }What is wrong here?
Thank you very much.April 29, 2022 at 1:26 AM in reply to: ✅autofill a select custom field with a custom field from another group. #35820Fernando Arbex
ParticipantHi long,
Thank you for your answer, I'm trying to make it work but need a hand.
Althought I have the direction I'm quite stucked on how to make it work.
I found a few codes on the internet that does that and I modified for my scenario.
Here is the code.<?php
function autoPopulateLeader( $field ) {
// reset lider_membro
$field['lider_membro'] = array();
// get the value of post_title (leader) from Custom Group with id
// informacoes_celula without any formatting
$choices = rwmb_get_value( 'post_title', 'informacoes_celula' );
// explode the value so that each line is a new array piece
$choices = explode("\n", $choices);
// remove any unwanted white space
$choices = array_map('trim', $choices);
// loop through array and add to field 'lider_membro'
if( is_array($choices) ) {
foreach( $choices as $choice ) {
$field['lider_membro'][ $choice ] = $choice;
}
}
// return the field
return $field;
}Notes:
- lider_membro is custom field (group ID membro) that I want to be populated from the post_title of the group ID informacoes_celula
- post_title is the leader custom field in the group ID informacoes_celula
- this code is in code snipet to load on all pages
- in the custom field type for lider_membro I used Select and callback: autoPopulateLeaderApril 26, 2022 at 11:59 PM in reply to: ✅autofill a select custom field with a custom field from another group. #35803Fernando Arbex
ParticipantHi Long,
You mean, create a function in Code Snipets called function_name (for example), and call it in the select field?
The select field has this message below:
To use a PHP function that returns an array of options, enter callback: function_name.
The callback function must be declared before adding to the box.So I would enter callback: function_name?
Is that it?
Fernando Arbex
ParticipantHi Long,
I don't use a theme, only oxygen builder that disables a theme.
I'll try to replicate in a new WP with very few plugins and see how it goes.Fernando Arbex
ParticipantHi Long,
I tried using the code you instructed but didn't work, see image below:
I also tried inserting the post ID direct on it, see it:
Geting the post IDAnd using on the code:
Using the code on Code blockIs there anything wrong I did?
This is a post type I created with metabox that is called celula.
Thank you.
Fernando Arbex
ParticipantHello Long,
You got it right. You helped a lot.
Thank you so much.
Fernando Arbex
ParticipantIn fact there is a strange bug.
I removed the last group and then I was able to Select the post type again.
If I duplicate or try to create any more field it disappears and post type go do default.Looks like a limitation.
I checked my server and there is no lack of space, memory and disk whatsoever.
I'm using PHP7.4 but also tried with 8.0 and nothing.Fernando Arbex
ParticipantHey Long, thank you for the reply.
My RestAPI is ok as you can see on the image bellow:
https://s.goforit.vip/kpu40x7GThere is a very odd thing also happening.
When I start adding more custom fields it just stops showing.
Like there is a limit.I was folowing this tutorial of Metabox...
https://www.youtube.com/watch?v=8nZwyBbAWXUWhen I duplicate to Friday it does not save.
And after that the Post type is reseting to default. I change it to the Post Type I created and it does not save anymore. (see image bellow) -
AuthorPosts