• Resolved liranrak

    (@liranrak)


    Hi Vrata, I’m trying to expend a little the dynamic checkboxes data and hope to get from you directions and ideas… ????

    My goal is to GET from each post a metadata value (in my case – price), and add it to the item’s html as custom attribute (in the way there is the “data-permalink=“ to have also “data-price=”).

    So you have any suggestions or ideas on the way to achieve this?

    At the end I attend to display the selected post’s price in the form, I’m sure it will be useful in the future for others developers too.

    Hoping to collaborate and cooperate together with you ????

    Best wishes,
    Liran

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    So you have any suggestions or ideas on the way to achieve this?

    yes, there is a built in hook to achieve this.

    add_filter('cf7sg_dynamic_checkbox_options_attributes','filter_post_attr', 10,4);
    function filter_post_attr($attributes, $post, $tag, $cf7_key){
    //$tag is a WPCF7_Tag object, $tag->name contains the field name.
    //$post is the post object.
    //get your price field values and put it into the $attributes array,
    $price=...;
    $attributes['data-price'] = $price;
    return $attributes;
    
    }
    Plugin Author Aurovrata Venet

    (@aurovrata)

    the filter is availabe when you,

    1. click the php icon on your UI editor cell containing the dynamic field
    2. select the filter from the list

    filter

    Thread Starter liranrak

    (@liranrak)

    Hi Vrata, first thank you for your super quick response.

    The filter you mentioned first (cf7sg_dynamic_checkbox_options_attributes) did successfully added new attribute tag! ????

    Unfortunately, I can’t seem to understand how to loop through your $post query in the filter and GET metadata value for each $post.
    I’ll be happy If you could show a simple working code example of how to add for each $post “data-id=$post->post_id”

    the filter is availabe when you

    You should also know that I did tried to use the filter through the php icon filter list as you after described, but it doesn’t paste the right hook (cf7sg_dynamic_checkbox_options_attributes) but the hook: cf7sg_dynamic_list_options_attributes…

    Waiting for your response,
    Liran

    Thread Starter liranrak

    (@liranrak)

    Unfortunately, I can’t seem to understand how to…

    My mistake, I used the wrong tag ?????♀?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    no worries

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘getting data from posts in dynamic checkbox’ is closed to new replies.