It seems you are comparing GMT time with the local time before you update the user meta.
Try WP function current_time( $type, $gmt = 0 );
$current_time = current_time('timestamp', 0) // local time
$current_time = current_time('timestamp', 1) // GMT time
I think you need
$current_time = current_time('timestamp', 0) // local time
instead of
$current_time = time();
Also take a look at current_time function
Edit:
Also i noticed your code where:
if( ($current_time < $user_start) && ($current_time > $user_finish) ) {
update_user_meta( $user_id, 'mblocation', 'away' );
}
$current_time
is in Unix timestamp format and the $user_start
or $user_finish
is in formatted date, you should convert $user_start
and $user_finish
to timestamp as well. You need to do the same with other code where it is applicable.
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Schedule WordPress Auto-Updates to only run during business hours
- What happens when wp_cron is deactivated in WordPress?
- wp_schedule_single_event function not working
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- Why is wp-cron only executing on page visit?
- Does using WP-cron make the site slower for the user?
- wp_schedule_single_event not working: cron job is triggered but nothing gets executed
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How to set intervals in cron jobs?
- Switch from wp-cron to a server cron job
- What causes wp_schedule_single_event to fire off?
- WordPress cron job running more than once
- Cron: Update four post at Hour
- Activate Plugin Automatically After Set Time
- Better way to run heavy scripts using WordPress database
- WordPress Cron function is not working
- WordPress crob job performance
- Adding custom cron_schedule prior to wp_schedule_event
- How to export comments in WordPress?
- How can I call a function from one plugin within another plugin?
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Publish author posts only with editor approval?
- Customizing subject in comment notification e-mails
- WP showing “warning: call_user_func_array()”, What to do?
- How to make sure a wp-cron job runs
- Declare a function before plugin does on the theme functions.php file
- Generate Advanced Custom Fields box in custom admin menu page
- Removing user contact methods works from functions.php but not from a plugin
- While Using Static Pages, How Can I Get /blog into the URL of Each Post?
- Cron Job not working in plugin
- Use functionality of 2 wordpress plugins
- How can i change an image’s author?
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- Showing Co-Authors on post page
- jQuery Plugin to use WordPress functions in AJAX request
- Using plugin functionality in external php script not working
- Debugging Technique Question re: functions.php
- Override plugin with functions.php
- WP Job Manager Category Drop-down; Change Placeholder Text Via Filter
- Custom Taxonomy Tag Search
- Missing argument 3 for wp_register_sidebar_widget()
- Redeclare theme’s function in a plugin
- I have functions in my wordpress plugin. How do I get them to work for me?
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- Is there a way I can find wordpress posts that don’t contain a word?
- Change wordpress current_time function to different timezone
- How to override a plugin function wrapped in a class?
- How make a php script run only with wp-cron
- Edit Yoast SEO breadcrumbs output [closed]
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- Using a post-signup hook to get user details
- Restrict media upload size by format
- CMB2 toolkit: Compare 2 Dates and validate the Time
- Facebook Messager Plugin
- Automatic plugin updates not working
- Grab WordPress Salt Data From URL
- Basics of changing plugin output
- Why can’t I call a (member) function from within a foreach?
- Are there action hooks for comments?
- Return multiple values in a shortcode attribute
- get specific value of a array | PHP
- Shortcode Attributes to Return different $_POST
- Plugin onclick button activate other plugin
- Activate and deactivate plugin automatically
- dynamic name of the style for wp_enqueue_style
- WordPress function to add text warning on every pages [closed]
- Call javascript functions from each page
- Add_image_size not generating correct size
- I’m looking for a plugin to execute a specific task a certain time
- How can i call a functions.php function, from inside my plugin class?
- How to make WooCommerce payment method field optional?
- WordPress Custom Hook with Class method
- Allow a particular user to access a particular plugin?
- how to define a html folder to make it work with WordPress commands
- add a hook of Woocommerce to a plugin but it only shows and doesn’t function properly
- ACF Fields are not showing up on Homepage
- Get Shortcode output to database for static post_content
- Securing langugae folder
- Call function with button and return response
- Change custom rewrite rule when permalink is updated/changed
- Scheduled cron event removed from list automatically after sometime
- Configuring default woo commerce login with modal popup
- Save Post Permalink In .txt File
- Dynamically Modify s2member Options
- How To Add Code To WP Without Plugin or Functions
- Disqus comments count taking long to update
- plugin not hooking to my custom hook
- Populate select option with JSON file
- Home page letters
- How to pass value to a plugins shortcode?
- Find all strings between an enclosing shortcode
- Create csv file in plugin
- Trying to output a “Most visited blogs” list in wordpress multisite
- wordpress Search function is not working
- Activate and deactivate two plugins automatically at certain hours
- PHP Creating a formula from mysql db values and db stored math operator
- Make plugin admin page visible to other roles
- wp_enqueue_script doesn’t load JS in plugin