• Hi,I have a list of titles & I need to pass the correct title text to dynamic text field, I did throught ajax to request test.php file and load the form inside a div. it works but because my form shortcode is in test.php (to get the posted variable correct) makes the action attribute in my form = “/wp-content/themes/mytheme-child/test.php#wpcf7-f2120-o1” which causes the page went blank after I send email.

    1/ I’ve tried to use the code below to change the action attribute but it only work if shortcode is on a page (so not work when it is in test.php)…
    add_filter(‘wpcf7_form_action_url’, ‘wpcf7_custom_form_action_url’);
    function wpcf7_custom_form_action_url($url)
    {
    global $wpcf7_contact_form;
    $id_to_change = 2120;
    if ($wpcf7_contact_form->ID === $id_to_change)
    return ‘/contact/#wpcf7-f2120-o1’;
    else
    return $url;

    }

    so I wonder is there a way to change the action attribute even my shortcode is in a test.php file and wait to click to request by ajax? or is there another way to get the send and get posted variable within same page ( get it in dynamic text field (post or get method))?

    Please help me??

    • This topic was modified 8 years, 2 months ago by nisoran123.
    • This topic was modified 8 years, 2 months ago by nisoran123.
  • The topic ‘change action attribute when shortcode is in custom php file’ is closed to new replies.