Add action wpcf7_maybe_add_random_dir ?
-
Hello! Is it possible to somehow make an action wpcf7_maybe_add_random_dir for a function in your theme?
I need this so that files can be uploaded to s3 bucketexample code
add_action( 'wpcf7_maybe_add_random_dir', function($dir) { $rand_max = mt_getrandmax(); $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) ); $dir_new = path_join( $dir, $rand ); if ( wp_mkdir_p( $dir_new ) ) { return $dir_new; } return $dir; });this does not work(
code in plugin (contact-form-7/includes/file.php)
function wpcf7_maybe_add_random_dir( $dir ) { do { $rand_max = mt_getrandmax(); $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) ); $dir_new = path_join( $dir, $rand ); $rand_max = mt_getrandmax(); $rand = zeroise( mt_rand( 0, $rand_max ), strlen( $rand_max ) ); $dir_new = path_join( $dir, $rand ); } while ( file_exists( $dir_new ) ); if ( wp_mkdir_p( $dir_new ) ) { return $dir_new; } return $dir; }
The topic ‘Add action wpcf7_maybe_add_random_dir ?’ is closed to new replies.