Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • this helped me a lot but my case is kinda different, because i want to get the post title and make it appear in the email message.

    i re-edited the code edited by schulzjan so here’s may code. maybe somebody might use it.

    <?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;
    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 );

    i have solved this by means of this codes:

    first, i went to the plugin folder and edited, contact-form-7/modules/text.php
    and created a new function (please excuse my mistakes in naming conventions).

    1. i inserted this code:
    wpcf7_add_shortcode( ‘digit’, ‘wpcf7_text_shortcode_handler’, true );
    wpcf7_add_shortcode( ‘digit*’, ‘wpcf7_text_shortcode_handler’, true );

    after this:
    wpcf7_add_shortcode( ’email*’, ‘wpcf7_text_shortcode_handler’, true );

    2. i inserted this code:
    if ( ‘digit’ == $type || ‘digit*’ == $type )
    $class_att .= ‘ wpcf7-validates-as-digit’;

    after this:
    if ( ‘text*’ == $type || ’email*’ == $type )
    $class_att .= ‘ wpcf7-validates-as-required’;

    3. i inserted this code:
    add_filter( ‘wpcf7_validate_email*’, ‘wpcf7_text_validation_filter’, 10, 2 );
    add_filter( ‘wpcf7_validate_digit*’, ‘wpcf7_text_validation_filter’, 10, 2 );

    after this:
    add_filter( ‘wpcf7_validate_email’, ‘wpcf7_text_validation_filter’, 10, 2 );

    4. i inserted this code:
    if ( ‘digit’ == $type || ‘digit*’ == $type ) {
    if ( ” == $_POST[$name] ) {
    $result[‘valid’] = false;
    $result[‘reason’][$name] = $wpcf7_contact_form->message( ‘invalid_required’ );
    }
    elseif ( ” != $_POST[$name] && ! is_telnum( $_POST[$name] ) ) {
    $result[‘valid’] = false;
    $result[‘reason’][$name] = $wpcf7_contact_form->message( ‘invalid_digit’ );
    }
    }

    after this if code:
    if ( ’email’ == $type || ’email*’ == $type ) {
    if ( ’email*’ == $type && ” == $_POST[$name] ) {
    $result[‘valid’] = false;
    $result[‘reason’][$name] = $wpcf7_contact_form->message( ‘invalid_required’ );
    } elseif ( ” != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
    $result[‘valid’] = false;
    $result[‘reason’][$name] = $wpcf7_contact_form->message( ‘invalid_email’ );
    }
    }

    second, i went to contact-form-7/includes/functions.php to add the error message for the telephone number validation.

    1. i inserted this code:
    ‘invalid_digit’ => array(
    ‘description’ => __( “There is a field that sender is needed to fill in with numbers”, ‘wpcf7’ ),
    ‘default’ => __( ‘Please fill the required field with numbers.’, ‘wpcf7’ )
    )

    after this code:
    ‘invalid_required’ => array(
    ‘description’ => __( “There is a field that sender is needed to fill in”, ‘wpcf7’ ),
    ‘default’ => __( ‘Please fill the required field.’, ‘wpcf7’ )
    ),

    third, i went to the formatting file located at wp-includes/formatting.php and created a new function

    function is_telnum($telnum)
    {
    $regexp = ‘/^[0-9\+\-]{7,}$/’;

    if(preg_match($regexp, $telnum))
    return true;
    else
    return false;
    }

    NOTE:
    in my code, i created a function wherein the input text for the telephone number will accept minimum of 7 characters (this only includes numbers and characters + and -)

    example of valid inputs:
    +1234567
    01234567
    02-1234567

    Now to use it in the contact form 7, please use this tag just
    Your Phone</td><td>[digit* text-417]

    Last, i created this a required field hehe, haven’t work it as a not required field yet. sorry.

    @iridiax you are so correct with that link. i encountered the same error because i tried inserting a new function in function.php and created a separate php tag <?php ?> and right then on the header error always happens, when i tried placing my functions inside the same <?php ?> every function is residing, i tested the update post function and there was no more error. so cool~ i just don’t know why that happens, i believe it must work like any other coding process do. i’m just confused on that point.

    Forum: Plugins
    In reply to: Flash Fader Not Showing Up

    whoa adamt07 i did what you said and it made the whole thing work!!! cool!

    mmmbisto how did you do this as worpress header for a template??? i cannot integrate it to my theme… thanks

Viewing 5 replies - 1 through 5 (of 5 total)