Support » Plugins and Hacks » [Resolved] Use Contact Form to gather a page title

[Resolved] Use Contact Form to gather a page title

  • Hello!

    If there’s a way to make this work, it will be really powerful.

    THE TASK: I want to have the contact form quietly gather the page title or post title and report it in the email it sends to me. I have been tinkering with this code and cannot manage to figure it out.

    (I have no idea why, but the previous thread where we were discussing this has been closed even though there’s still evident confusion here. (http://wordpress.org/support/topic/plugin-contact-form-7-add-custom-field-management?replies=7#post-1226523) I need to keep this discussion going actually, thanks.)

    ** 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;
    global $wpdb;
    if ( ! is_array( $tag ) )
    return '';
    $type = $tag['type'];
    $name = $tag['name'];
    $post = get_the_ID();
    $querystr = "SELECT * FROM $wpdb->posts WHERE ID = $post ";
    $pageposts = $wpdb->get_row($querystr, ARRAY_A);
    $html = '<input type="hidden" name="'. $name .'" value="'.$pageposts['post_title'].'" />';
    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'];
    return $result;
    add_filter( 'wpcf7_validate_pagelink', 'wpcf7_pagelink_validation_filter', 10, 2 );

    Any ideas out there?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Use Contact Form to gather a page title’ is closed to new replies.