• Resolved saugstrup

    (@saugstrup)


    Hi,

    what is the best way to put information in the email from contact form 7 about the page url the form was submitted from?

    We are thinking about using the same contact for for a client site where the same form will be displayed on several different product pages. We need to know from what page the form has been submitted.

    How to do that best?

Viewing 8 replies - 16 through 23 (of 23 total)
  • I got the same error as thebookmistress.

    However, I deleted everything in the file again. Then made the tags as suggested and then reinserted all of the code and it worked.

    BTW, did some googling and found out that the error is related to some blank spaces I probably had at the end of my file.

    Still looking for a solution in the current version of CF7 – I’ve got half the code in place, just need to dot the i – would be great if someone had the rest of the puzzle – Contact form 7 source url

    pfizzi

    (@pfizzi)

    I’m really pleased with this solution, but I can’t make it work. I get a CF Validation Error when I send the form. I did everything like described above.

    That’s the code in pagelink.php:

    <?php
    /**
    ** module, which adds a computed values to be displayed in the resulting message:
    ** [pagelink name] -> permalink of that post/page is available via [name]
    **/
    
    /* Shortcode handler */
    
    function wpcf7_pagelink_shortcode_handler( $tag ) {
    global $wpcf7_contact_form;
    
    if ( ! is_array( $tag ) )
    return '';
    
    $type = $tag['type'];
    $name = $tag['name'];
    
    $html = '<input type="hidden" name="'. $name .'" value="'.get_the_ID().'" />';
    
    return $html;
    }
    
    wpcf7_add_shortcode( 'pagelink', 'wpcf7_pagelink_shortcode_handler', true );
    
    function wpcf7_pagelink_validation_filter( $result, $tag ) {
    global $wpcf7_contact_form;
    
    $type = $tag['type'];
    $name = $tag['name'];
    
    $thePageID = (int) $_POST[$name] ;
    
    if ( $thePageID == 0 ) {
    $result['valid'] = false;
    $result['reason'][$name] = 'Someone tampered with the form! Bad guy!';
    return $result;
    }
    
    $_POST[$name] = get_permalink($thePageID);
    
    return $result;
    }
    
    add_filter( 'wpcf7_validate_pagelink', 'wpcf7_pagelink_validation_filter', 10, 2 );
    
    ?>

    That’s my form:

    <p>Tu nombre<br />
        [text your-name 20/50] </p>
    
    <p>Tu email<br />
        [email your-email 20/50] </p>
    
    <p>Email de tu amigo<br />
    [email friend-email 20/40] </p>
    
    [pagelink mypagelink] 
    
    <p>Tu mensaje<br />
        [textarea your-message 20x5] </p>
    
    <p>[submit "Enviar"]</p>

    Are the tags inserted correctly like this?

    And finally that’s the message body:
    Haz click en este enlace para ir a la pagina: [mypagelink]

    Any ideas?
    Thanks

    pfizzi

    (@pfizzi)

    Does it only work with urls that contain the ?id paramater or does it work also with other types of permalinks eg https://www.example.com/category/product/ ?

    It works perfectly but it made my whole wordpress dashboard stop redirecting when I save about anything. Posts, Pages or contact forms.

    Any tricks to fix it ?

    Does anyone know how to add the entire url? The url my form comes from has an item number added to it but when it sends it only sends the url like this https://mysite.com/?page_id=224 But I need it to add the full url which would be https://mysite.com/?page_id=224&item=28186 with the item number. Right now it just leaves the item number off the end.

    nevermind, this is not working out for me. I cannot save anything without an error so I have removed this module. I need something that will insert the item id into the form. Any ideas?

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘[Plugin: Contact Form 7] Source URL for Contact form 7?’ is closed to new replies.