Hola,
Estoy intentando aumentar la memoria PHP porque el plugin Gravity PDF (junto con Gravity Forms) se queda corto al generar algunos PDFs.
El formulario puede generar 1 pdf o varios. Con 1 funciona bien pero si son 2 o más (hasta 6), da error.
Siguiendo indicaciones de varias IA, he probado:
Añadir este código en wp-config.php
// Optimización para Gravity PDF - Múltiples PDFs define('WP_MEMORY_LIMIT', '512M'); define('WP_MAX_MEMORY_LIMIT', '512M');
Añadir este código en functions.php
// Retrasar generación de PDFs para evitar sobrecarga add_filter('gfpdf_mpdf_init_class', function($mpdf, $form, $entry, $settings) { usleep(500000); // Espera 0.5 segundos entre PDFs return $mpdf; }, 10, 4);
Según Gravity PDF:
You can try changing your WP Memory directly in PHP. Edit your WordPress wp-config.php file and add the following before the /* That's all, stop editing! Happy blogging. */ line:
define( 'WP_MEMORY_LIMIT', '128M' ); /* change this to a higher value like 256MB or 512MB if needed */
More details about the WP_MEMORY_LIMIT constant can be found in the WordPress documentation.
If the wp-config.php method didn't work for you and you have access to your php.ini file, try changing the memory_limit line to the following:
memory_limit = 128M;
A lot of shared and managed hosting don't allow you to edit the main php.ini file, but some do allow you to upload your own version which overrides these parameters. Check your web hosting provider's documentation to see if they support this.
If none of the above two options works, you can try changing the memory limit using the .htaccess file. Be aware that if this doesn't work, it may cause a 500 Internal Server Error (remove the line if this happens).
php_value memory_limit 128M
If none of the methods above work for you, then get in touch with your web hosting provider and ask them for assistance.
Con lo cual, como ya estaba hecho el paso del config.php he ido a por el de php.ini
He añadido:
; --- ajustes personalizados ---
memory_limit = 512M
Pero no tengo claro cuál de estos métodos funciona realmente en los servidores de Webempresa.
¿Alguien sabría cuál es la forma correcta para que se apliquen estos cambios y funcione correctamente la generación de varios pdf?
Gracias