get_currentuserinfo()
is a pluggable function, it is not available during plugins load stage.
That aside you shouldn’t be adding filter conditionally, but use data provided by the filter. If you take a look at filter calls:
apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember )
$user_id
is provided as second argument. You just have your filter listen for it and modify return conditionally on it.
Here’s an untested example:
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year', 10, 3 );
function keep_me_logged_in_for_1_year( $ttl, $user_id, $remember ) {
if( 123 === $user_id )
$ttl = YEAR_IN_SECONDS;
return $ttl;
}
Related Posts:
- Cookie value changes back to previous value after changing
- How can I store user preferences in WordPress and retreive them later?
- Every time I use wp_get_current_user() my plugin breaks
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- Plugin update error message
- Customizing subject in comment notification e-mails
- if plugin is active? check if plugin is enabled or not?
- Checkbox show / hide output result
- Custom Logo Link WordPress
- How to convert Currency from USD to other IP Based currency in Php function
- how to validate input field in wordpress generated with wpform plugin
- add_rewrite_rule to load different page, without changing URL in browser
- implement custom roles in custom plugin
- WordPress Custom Hook with Class method
- How to get current cart values using WC_Shortcodes?
- Attempting to list all product categories and the price range of all products within them
- Allow a particular user to access a particular plugin?
- WP Function does not trigger on Webhook API Call
- Creating an array from form inputs before it is posted to the options database
- Post source link plugin – small modification
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- Share my WordPress plugin for updating how?
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- adding dynamic/multiple slug values in ‘option_none_value’
- How to create algorithm for ordering posts in WordPress?
- Submitting form to PHP
- Adding discount functionality to the cart
- How to assign a specific service to a specific provider based on location
- Precheck fields when I add a new post
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Get Shortcode output to database for static post_content
- working code, not working – Plugin Dev
- Easiest way to load/fire a handful of functions, IF checkbox is checked?
- Block plugin update possibilities (but not by hiding notifications)
- post id or permalink auto-incrementing number and reset everyday
- Change custom rewrite rule when permalink is updated/changed
- Is admin section completely customizable in terms of styling?
- Return function results within shortcode
- Configuring default woo commerce login with modal popup
- How to make the first letter of a post title uppercase, in a plugin?
- Update User Meta Via Ajax
- Compare Ajax Data Results
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- Soflyy WP All Import Custom File Download Issue
- register_activation_hook doesn’t fire at all
- Update (a function) post’s featured image as soon as $image_url changes
- Migrating custom php we wrote from functions.php into a site-specific plugin
- Nested DIV’s across functions in PHP, do not seem to work
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- How can I save cookies to members
- Populate select option with JSON file
- How to order users alphabetically by name? in plugin UPME
- How to echo a plugin’s function into a template?
- How to replace native comment_count with Comments Evolved aggregate count
- Find all strings between an enclosing shortcode
- It possible to implement an adhoc php web application with wordpress?
- Create csv file in plugin
- Cannot access variables within a widget
- Is there any wordpress function to update a random post every 10 minutes?
- Calling an custom field from theme option at the frontend
- Posting code inside the post instead of in the template file using shortcode
- WordPress function to add text
- Saving an array to get_options
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- Metabox Data not saving
- How to add a handler for a button in plugin?
- Contact Form 7: custom validation [closed]
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- date function not correctly returning date
- Doing action based on input from options menu
- Including a PHP file via a function that is part of a plugin?
- Showing author box on post detail page
- How to disable register and reset the password from WordPress admin panel?
- How use Dynamic hyperlink on each wordpress post?
- How to prevent page load on form submission
- Move related products after product summary? [closed]
- How to tweak a plugin without preventing it from updating
- is_plugin_active() not defined on active plugin, in the thumbnails.php file
- Undefined constant error in pluggable.php
- Adminimize Plugin — Is there an alternative to limiting Editor to ‘Appearance > Widgets’ only?
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Woocommerce disable checkout on specific day
- Requires PHP version 5.3.0
- WordPress: code structure
- PHP if url extension action=discussion condition use [closed]
- Adding a script & php to functions.php
- PHP Creating a formula from mysql db values and db stored math operator
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Option value not getting updated until page refresh in WordPress
- Make plugin admin page visible to other roles
- WordPress Convert queries to slashes using function.php
- How to change all the urls of the WordPress site?
- Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
- WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)
- I want to allow certain file types on dokan upload files
- stop resize button for wordpress media
- Mixed results with is_page() WordPress function, when using $this, or self
- Read page- or post-content across different builder-plugins