• Resolved bradkacz

    (@bradkacz)


    Hi,
    i try change upload files outside media library, to directory for example ‘form-uploads’. Checkboxes Attach to Mailer, Allow Multiple and Add to Media Library are off. I have functions.php in child-theme, field_id copy from actual form.
    I created directory form-uploads in /wp-content/uploads/form-uploads and set chmod 777.

    Url added file from mail is still
    https://prototyp.zsto.cz/wp-content/uploads/f1f15d409e4e5e53e773a84e80673769/test-pdf-1.pdf and file isn’t here.

    my code from functions.php:
    add_filter( ‘caldera_forms_upload_directory’, function( $dir, $field_id ){
    if( ‘fld_1720034’ == $field_id ){
    $dir = ‘form-uploads’;
    }
    return $dir;
    }, 20, 2 );

    /** Wait until caldera_forms_core_init hook so we know all actions were added **/
    add_action( ‘caldera_forms_core_init’, function() {
    //File delete is attempted first here, but if an email should send, the file isn’t deleted//
    remove_action( ‘caldera_forms_submit_complete’, array( ‘Caldera_Forms_Files’, ‘cleanup’ ) );

    //If email is set to be used, we wait until email is sent to delete on these hooks:
    remove_action( ‘caldera_forms_mailer_complete’, array( ‘Caldera_Forms_Files’, ‘delete_after_mail’ ), 10, 3 );
    remove_action( ‘caldera_forms_mailer_failed’, array( ‘Caldera_Forms_Files’, ‘delete_after_mail’ ), 10, 3 );

    //Just in case of a never completed submission or some other issue, a CRON job is used to delete the file
    remove_all_actions( Caldera_Forms_Files::CRON_ACTION );

    });

    Thank you for any help

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor christiechirinos

    (@christiechirinos)

    While we can’t help you troubleshoot or provide specific directions for custom code modifications, there are many resources available that can point you in the right direction:
    If you’re adding CSS to your site, review our recommendations for where to put your code, recommended themes, tutorials, and other best practices. https://calderaforms.com/doc/adding-custom-style-caldera-forms/
    On the documentation page for any of our hooks, for example this one, there is a panel at the end with the header “Where Does This Code Go?” That gives you links to introductory articles about what WordPress hooks are, why you use them and how to use them.
    Caldera Forming is our customer and developer forum. As a part of this community, you can ask fellow Caldera Forms users for help with custom code and design. https://www.facebook.com/groups/651862761663883
    If you’re looking for comprehensive assistance in developing your site (as opposed to small code modifications), or if you’d rather leave the customization to the professionals, consider reaching out to someone from our list of recommended developers: https://calderaforms.com/recommended-developers/.
    Visit our developer documentation for tutorials and troubleshooting help. https://calderaforms.com/category/developer-api/
    If you’re adding code from a third-party source, we recommend reaching out to the source for help.

Viewing 1 replies (of 1 total)
  • The topic ‘Can’t change upload folder’ is closed to new replies.