• Resolved Leslie Carson

    (@lunabug)


    I need to pass the post ID to a popup. I have a list of posts and in the list is a link to open a popup, which is a form to complete and pass the post information and the form information to the administrator.

    My exact scenario:
    I have a list of posts that are events, I need to use the excerpt to create a button if a volunteer is needed for the event. I’m not able to use any of the post data except title, date/time, location, and the excerpt from the post.

    In the excerpt I’m creating an html button to open the popup (Volunteers needed for this event!) the popup opens just fine using the css selector a[href*=”/event_volunteer/”].

    How do I pass the lbpostid 25002 to the popup?

    Ideally would be for me to put the form shortcode into the excerpt however the excerpt in my theme won’t allow it so I’ll looking for alternatives.

    Thanks,
    Leslie

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    @lunabug – In this case your gonna want to use JavaScript. This means you load one form, no matter how many listings are there it works great. You will do something like

    
    add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
    function my_custom_popup_scripts() { ?>
    <script type="text/javascript">
    	(function ($, document, undefined) {
    
    $('a[href*=”/event_volunteer/”]').click(function (event) {
      var $this = $(this),
          id = $this.parent.attr('id');
    
      /* Set the value of your field to whatever you like here */
      $('form #cf7_field_id or CSS selector here').val(id);
    
      event.preventDefault();
    });
    
    	}(jQuery, document))
    </script><?php
    }
    
    Thread Starter Leslie Carson

    (@lunabug)

    THANK YOU FOR YOUR HELP, but I can’t get this to work.

    Here’s the button: <a class="button" href="/event_volunteer/">Volunteers needed for this event!</a>

    Here’s the code you wrote with my field named “lb_event_id”:

    add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
    function my_custom_popup_scripts() { ?>
    <script type="text/javascript">
    (function ($, document, undefined) {
    $('a[href*="/event_volunteer/"]').click(function (event) {
    var $this = $(this),
    id = $this.parent.attr('id');
    /* Set the value of your field to whatever you like here */
    $('lb_event_id').val(id);
    event.preventDefault();
    });
    }(jQuery, document))
    </script><?php
    }

    Here’s the test page: https://alg.websitesbylunabug.com/events/ (scroll down, the buttons for this are black)

    In my caldera form, I’m using a hidden field with this {get:lb_event_id} (I’ve also tried the request tag); but it’s empty.

    What am I missing?

    Plugin Author Daniel Iser

    (@danieliser)

    @lunabug – Sorry I didn’t reply sooner.

    Looks like I gave you a few typos.

    Try

    
    add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
    function my_custom_popup_scripts() { ?>
    <script type="text/javascript">
    	(function ($, document, undefined) {
    
    $('a[href*=”/event_volunteer/”]').click(function (event) {
      var $this = $(this),
          id = $this.parent().attr('id');
    
      /* Set the value of your field to whatever you like here */
      $('input[name="lb_event_id"]').val(id);
    
      event.preventDefault();
    });
    
    	}(jQuery, document))
    </script><?php
    }
    

    Now, I couldn’t find a field on the page with that name, so we may need to update the CSS selector input[name=”lb_event_id”] to match that field specifically. Where can I see the form in question?

    Plugin Author Daniel Iser

    (@danieliser)

    Closing this ticket due to inactivity. If you’re still having an issue, create a new thread, link this one, and we will continue troubleshooting.

    Please take a moment to rate and review the plugin and or support.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pass Post ID to Popup’ is closed to new replies.