• Resolved doeri

    (@doeri)


    I am getting the message “The snippet has been recently deactivated due to an error on this line” on the bolded line.

    add_filter( ‘mfrh_new_filename’, ‘my_custom_filename’, 10, 3 ); function my_custom_filename($new, $old, $post) { // Get the ACF field $acf_field = get_field(‘your_acf_field’, $post->ID); $product_index = get_option(‘_product_index’, 1); // Generate filename $filename = ‘web_’ . sprintf(‘%04d’, $product_index) . ‘ – ‘ . sanitize_title(get_the_title($post->ID)) . ‘ – ‘ . $acf_field; // Increment the product index for the next upload update_option(‘_product_index’, $product_index + 1); return $filename; }

    • This topic was modified 9 months, 3 weeks ago by doeri.
Viewing 1 replies (of 1 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @doeri,

    Yes, that indicates there is an error in the PHP snippet, what is the error message? The plugin should also indicate the error you are getting – or if you have error logging enabled you will be able to see the error in the log.

    I’m not 100% sure since the code you pasted lost some of the formatting but you might be running into an error due to using sprintf incorrectly. Also, where you are calling get_field you likely need to replace “your_acf_field” with the actual ACF field you set up for this.

    The fix here is to make sure your PHP snippet does not throw any errors – WPCode attempts to help with that by indicating the error message and the line where it’s happening.

Viewing 1 replies (of 1 total)
  • The topic ‘The snippet has been recently deactivated due to an error on this line’ is closed to new replies.