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
- WordPress “wp cron event run” as Siteground cron job
- Cron Job not working
- Which approach for managing automatic updates would be more robust?
- Manually set global $post vars with an ID, in order to use template tags
- How to not allow users to create new tags, but allow to them to use existing ones
- Limit access to posts/pages by user roles
- Remove Google Fonts Which Are (Probably) Added By Plugins
- Common functionality between my own plugins
- Adding a text domain to every __(), _e() and __n() gettext call without a plan to create own translations
- Editor access to plugin settings
- Saving Plugin settings to the database
- Shortcode display outside the div
- Removing user contact methods works from functions.php but not from a plugin
- Custom Widget outputs the input but doesn’t save anything inside the textarea
- How to use wp-ajax in wp-cron
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- Where to place custom functions?
- Redeclare theme’s function in a plugin
- AJAX button run function
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- Display post lists in 2nd paragraph
- How to display custom sidebar in wordpress 5.5.2
- creating html reusable blocks via shortcodes
- Replacing a plugin function with a custom renamed function doesn’t work
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- Disqus deleted comments are syncing with wordpress but active comments do not
- date/time-picker and file upload (image) fields for custom fields (e.g. with more fields)
- WordPress metaboxes – textfield suggestion automatically populated
- How to create an option page for this simple plugin
- What is @Action in WordPress?
- the_tags : can we insert a class
- Check if variable is set in filter
- WordPress checkbox and Illegal string offset
- Undefined index: action plugin problem
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Adding class to last list item? Not WP generated
- I changed .live() to .on() but change is not reflected on the server
- wp_enqueue_scripts
- WordPress Console Application (ability to excecute a custom function via crontab only)
- How can I fetch data from another website to my wordpress website with mysql database
- how to change wp-admin url using function file
- Add the_post_thumbnail_url to a shortcode in function.php
- Changing plugin options from theme functions file?
- Expected ‘add_filter’ (T_STRING)
- Could not add ‘LoginLogout’ link using BAW login logout plugin
- My widget won’t update its values when save is clicked
- Adding a Tag Parameter / Filter to My Shortcode
- Adding a pagenavi to function for displaying bookmarks
- What is the most efficient way of adding additional functionaliy for admin only
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Replace the_content with ACF Flexible Content via function
- Create category for each user
- Bulk updating a group of WordPress Pages every 10 minutes
- Cookie value changes back to previous value after changing
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- Cannot pass value variable to WP AJAX functions
- Sharing varible between two add_actions
- How to create algorithm for ordering posts in WordPress?
- Easiest way to load/fire a handful of functions, IF checkbox is checked?
- post id or permalink auto-incrementing number and reset everyday
- Override filter variable not working
- Soflyy WP All Import Custom File Download Issue
- Update (a function) post’s featured image as soon as $image_url changes
- Why is WP template_include overwritting all templates rather than specified page?
- Why isn’t my plugin seeing other classes?
- How to add submenu to WordPress plugin in the same Directory of main Plugin?
- Contact Form 7: custom validation [closed]
- functions.php conditional output for a single plugin
- Access to wordpress method inside of classes
- How to set-up multiple cron task with wp_schedule_event so that they do not overlap?
- Single dash converted to double dash
- How use Dynamic hyperlink on each wordpress post?
- How to declare this function correctly?
- Can’t modify plugin function
- PHP if url extension action=discussion condition use [closed]
- filter just a portion of plugin function
- Make plugin admin page visible to other roles
- wp_enqueue_script doesn’t load JS in plugin
- Read page- or post-content across different builder-plugins
- Remove posts that start with similar words (like a delete duplicate posts plugin)
- How to get next day date of a specific day