WordPress filter hook · part of WordPress core

nonce_life

A WordPress core filter that 28 plugins also fire themselves, running on 7.3M+ sites between them.

“Filters the lifespan of nonces in seconds.”

How to use nonce_life

It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'nonce_life', function( $value, $action ) {
	// Change $value here.
	return $value;
}, 10, 2 );

Argument names come from LiteSpeed Cache's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

28 plugins that fire nonce_life

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. LiteSpeed Cache icon LiteSpeed Cache7+ million installs apply_filters( 'nonce_life', DAY_IN_SECONDS, $action ) src/esi.cls.php:950
  2. GiveWP icon GiveWP100,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/misc-functions.php:1977
  3. hCaptcha for WP icon hCaptcha for WP70,000+ installs apply_filters( 'nonce_life', constant( 'DAY_IN_SECONDS' ) ) src/php/AutoVerify/AutoVerify.php:924
  4. Uncanny Automator icon Uncanny Automator40,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) src/core/services/rest-routes.php:399
  5. IP Location Block icon IP Location Block10,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) src/Support/Util.php:741
  6. xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN icon xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN10,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, (string) $action ) includes/class-cache.php:5548
  7. Pantheon Advanced Page Cache icon Pantheon Advanced Page Cache10,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) inc/admin-interface.php:670
  8. IP Geo Block icon IP Geo Block7,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) classes/class-ip-geo-block-util.php:381
  9. FAZ Cookie Manager icon FAZ Cookie Manager3,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/class-dsar-shortcode.php:1220
  10. Premium Blocks icon Premium Blocks2,000+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, 'pbg_form_nonce' ) classes/class-pbg-blocks-helper.php:985
  11. BaseCloud Boost icon BaseCloud Boost50+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, 'gform_ajax_submission' ) includes/Core/Token_Expiry.php:73
  12. Gratora icon Gratora40+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, 'wp_rest' ) src/Core/Commands/CoreCommandProvider.php:1845
  13. Presentero icon Presentero30+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, self::NONCE ) includes/class-presentero-gc-ajax.php:89
  14. Noncensible icon Noncensible20+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS, $action ) noncensible.php:40
  15. Ask My Content icon Ask My Content20+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) ask-my-content.php:206
  16. Gorilla Cache icon Gorilla Cache20+ installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/class-gorillacache-installer.php:592
  17. Coyote Speed for Divi icon Coyote Speed for DiviFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/class-cache.php:171
  18. Pixel Made Simple icon Pixel Made SimpleFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, self::NONCE_ACTION ) includes/class-pxms-forms.php:89
  19. Mapsemble icon MapsembleFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) src/Admin/BlockPreview.php:222
  20. Visual Edit Lite icon Visual Edit LiteFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/class-forms.php:485
  21. Plattivo icon PlattivoFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, 'wp_rest' ) src/Rest/AuthController.php:69
  22. Rox Rental Booking icon Rox Rental BookingFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) src/Modules/Frontend/Services/PublicConfigService.php:126
  23. Mix News Tools icon Mix News ToolsFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, 'mix-news-view-' . get_queried_object_id() ) inc/performance.php:120
  24. Cachelume icon CachelumeFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/CacheHandler.php:367
  25. Nonce Failure Explainer icon Nonce Failure ExplainerFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS ) includes/class-noncfaex-environment.php:36
  26. ZeroConfig icon ZeroConfigFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, '' ) includes/class-page-cache.php:370
  27. Edge Doctor for Cloudflare® icon Edge Doctor for Cloudflare®Fewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, -1 ) src/Check/PrivateCache/C6NonceAge.php:239
  28. Thorakis Cache icon Thorakis CacheFewer than 10 installs apply_filters( 'nonce_life', DAY_IN_SECONDS, -1 ) src/Config/Ttl.php:62

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.