post meta value as shortcode parameter

// hijack the download shortcode add_shortcode( ‘dlm_gf_form’, array( $this, ‘shortcode_dlm_gf_form’ ) );

This line just adds a shortcode from a class. I checked this plugin’s class and they didn’t provide any actions or filter. You can try to modify original code of this plugin for your purposes only. I don’t see any other solution. I don’t know what this plugin even do, just looking at source code and trying to understand the logic, so my advice is not tested)

Open file dlm-gravity-forms.php
From the line 156 you will see this code:

// the download_id is a required attribute
if ( ! isset( $atts['download_id'] ) ) {
    return 'Download Monitor - Gravity Forms Error: No download_id set!';
}

It’s a check if download_id is set. Just after this if statement you can add the same code from previous question with the same logic – if download_id is not a number – get post meta value from post meta with a name you pass in download_id attribute:

    if( !is_numeric($atts['download_id']) ):
        $post_meta = get_post_meta(get_queried_object_id(), $atts['download_id'], true);
        $post_meta ? $atts['download_id'] = $post_meta : null;
    endif;

Save changes 😉

Leave a Comment