Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Increase memory and execution time for WP admins only.
Increase memory and execution time for WP admins
You can add code to your php.ini, .htaccess, or wp-config.php
to increase execution times and memory limits to get WordPress
and PMPro to work when it needs more memory, time, or both.
However, sometimes you only need the extra memory and time
when doing something an admin would be doing... like exporting
a members list or orders table.
If this is the case, you can use this code to selectively
increase the execution time and memory for admins only.
This will make sure that normal visitors don't end up
using more memory or apache/etc services than they need to,
which should make your site run smoother.
function my_init_memory()
if(current_user_can("manage_options") || current_user_can("pmpro_memberslistcsv") || current_user_can("pmpro_orderscsv"))
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
ini_set('memory_limit', '256M');
add_action('init', 'my_init_memory', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.