Support Forum » User Profile

Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • Fernando ArbexFernando Arbex
    Participant

    Very 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?

    Fernando ArbexFernando Arbex
    Participant

    Hi 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.

    Fernando ArbexFernando Arbex
    Participant

    Hi 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.

    Fernando ArbexFernando Arbex
    Participant

    Hi 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: autoPopulateLeader

    Fernando ArbexFernando Arbex
    Participant

    Hi 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?

    in reply to: Display Google Maps on Oxygen Builder Repeater #35748
    Fernando ArbexFernando Arbex
    Participant

    Hi 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.

    in reply to: Display Google Maps on Oxygen Builder Repeater #35726
    Fernando ArbexFernando Arbex
    Participant

    Hi Long,

    I tried using the code you instructed but didn't work, see image below:

    Adding get_the_ID"

    I also tried inserting the post ID direct on it, see it:
    Geting the post ID

    And using on the code:
    Using the code on Code block

    Is there anything wrong I did?

    This is a post type I created with metabox that is called celula.

    Thank you.

    in reply to: Loading fields... never loads #34155
    Fernando ArbexFernando Arbex
    Participant

    Hello Long,

    You got it right. You helped a lot.

    Thank you so much.

    in reply to: Loading fields... never loads #34145
    Fernando ArbexFernando Arbex
    Participant

    In 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.

    in reply to: Loading fields... never loads #34135
    Fernando ArbexFernando Arbex
    Participant

    Hey Long, thank you for the reply.
    My RestAPI is ok as you can see on the image bellow:
    https://s.goforit.vip/kpu40x7G

    There 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=8nZwyBbAWXU

    When 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)

    https://s.goforit.vip/7KuqDrEN

Viewing 10 posts - 1 through 10 (of 10 total)