Set shortcode post_id via functions.php

Support MB Frontend Submission Set shortcode post_id via functions.phpResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8730
    pattepatte
    Participant

    Hey guys,

    since a few hours I'm running in a problem and I hope you can help.

    I'm trying to set the value for the shortcode post_id via functions.php. I'm not setting it via GET parameter in the url and not via attribute in the wysiwyg editor of the post where I have embedded the form.

    So here is my code:

    add_filter( 'rwmb_frontend_field_value_post_id', 'my_custom_population_function', 10, 2 );
    function my_custom_population_function( $value, $args ) {
        if ( $args['id'] === 'car_informations' ) {
            $value = 123;
        }
        return $value;
    }
    $value = apply_filters( "rwmb_frontend_field_value_post_id", $value, $args );

    Maybe an important information. By trying to debug the problem, I've tried to print_r the $args array before the if() and it's empty.

    Do you have any ideas?

    Would be really cool – thank you! 🙂

    Christoph

    #8745
    Anh TranAnh Tran
    Keymaster

    Hello Christoph,

    I've just tried to debug that, here is my similar code: https://i.imgur.com/gh4PTcA.png
    And here is how it appears in the frontend: https://i.imgur.com/sYO8S4U.png

    Can you take a screenshot of your full code?

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.