• Resolved arthurmello1

    (@arthurmello1)


    Hi Ron!

    I know it is already annoying, because I’m posting and posting here, but, check out below my new problem:

    I’m using the Contact Form 7 plugin, with an attachment resource, and I need the attached files sent via form are automatically deleted from the server, however this is not happening …

    The functions that do are there, but the files remain in the folder wp-content \ uploads \ wpcf7_uploads …

    NOTE: my first step was entering in contact with the plugin’s developer, and he told me to return to the default theme, for a simple test. I did this and the function to remove the uploaded files from the server worked like a charm immediately!

    I want to know if you have any suggestion to fix this issue in your theme, if know some compatibility problem with this kind of function with your theme or something.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter arthurmello1

    (@arthurmello1)

    Ah! Here’s the code’s part of the plugin responsible for the upload/removing files from the server:

    /* File uploading functions */

    function wpcf7_init_uploads() {
    $dir = wpcf7_upload_tmp_dir();
    wp_mkdir_p( trailingslashit( $dir ) );
    @chmod( $dir, 0733 );

    $htaccess_file = trailingslashit( $dir ) . ‘.htaccess’;
    if ( file_exists( $htaccess_file ) )
    return;

    if ( $handle = @fopen( $htaccess_file, ‘w’ ) ) {
    fwrite( $handle, “Deny from all\n” );
    fclose( $handle );
    }
    }

    function wpcf7_upload_tmp_dir() {
    if ( defined( ‘WPCF7_UPLOADS_TMP_DIR’ ) )
    return WPCF7_UPLOADS_TMP_DIR;
    else
    return wpcf7_upload_dir( ‘dir’ ) . ‘/wpcf7_uploads’;
    }

    function wpcf7_cleanup_upload_files() {
    $dir = trailingslashit( wpcf7_upload_tmp_dir() );

    if ( ! is_dir( $dir ) )
    return false;
    if ( ! is_readable( $dir ) )
    return false;
    if ( ! wp_is_writable( $dir ) )
    return false;

    if ( $handle = @opendir( $dir ) ) {
    while ( false !== ( $file = readdir( $handle ) ) ) {
    if ( $file == “.” || $file == “..” || $file == “.htaccess” )
    continue;

    $stat = stat( $dir . $file );
    if ( $stat[‘mtime’] + 60 < time() ) // 60 secs
    @chmod( $dir . $file, 0755 );
    @unlink( $dir . $file );
    }
    closedir( $handle );
    }
    }

    if ( ! is_admin() && ‘GET’ == $_SERVER[‘REQUEST_METHOD’] )
    wpcf7_cleanup_upload_files();

    Theme Author ronangelo

    (@ronangelo)

    if you know some compatibility problem with this kind of function with your theme or something.

    I don’t know of any. There’s absolutely nothing on the theme that has anything to do with handling server files.

    Suggestions:
    – Check all the custom code you have added on the theme both on template files and on functions.php. You may have added something previously that might be the cause.

    – Just try deactivating plugins. I’ve read your post on the plugin page where you mentioned that you did not even try since you managed to make it work the first time.

    – Set debug to true on your wp-config file so that error messages are displayed if there are any. Better yet, check your server log files to see any error messages there.

    – Check your code again, especially the function wpcf7_cleanup_upload_files(). There seems to be some opening and closing brackets that are missing.

    Thread Starter arthurmello1

    (@arthurmello1)

    Ok, thanks for the suggestions!

    I’ll try this steps and then I’ll post here the results!

    Thank you again!

    Thread Starter arthurmello1

    (@arthurmello1)

    Problem solved!

    The cause was a plugin that I was not even using!

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Contact Form 7 in Frontier theme’ is closed to new replies.