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:
- CPU Overloading due to some hooks
- 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
- How to use a class from another plugin
- Override Plugin Script Fucnction in WordPress
- How to display custom sidebar in wordpress 5.5.2
- Calling plugin function inside custom plugin for onclick event
- Show function to super admin
- creating html reusable blocks via shortcodes
- CMB2 toolkit: Compare 2 Dates and validate the Time
- get current date + 90 days and checking every day
- Adding a new field to the address field type in gravity forms
- Replacing a plugin function with a custom renamed function doesn’t work
- How to create an input field, and base the output on spreadsheet data? [closed]
- Facebook Messager Plugin
- Nested shortcode functions accessing variable
- How to make a implement queue for scheduling tasks in WordPress?
- Calling an attribute from a plugin shortcode
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- How to call WordPress function other files
- All sites themes functions.php have been changed
- Customize permalink wordpress category id
- Conditional attributes and logic per product category
- Disqus deleted comments are syncing with wordpress but active comments do not
- Admin style for just one plugin in dashboard
- Automatic plugin updates not working
- WP Query. Is there a maximum size?
- How to remove custom post type and add category and post name
- Grab WordPress Salt Data From URL
- date/time-picker and file upload (image) fields for custom fields (e.g. with more fields)
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- WordPress get_avatar function not correct working
- Cron Job not working in plugin
- WordPress metaboxes – textfield suggestion automatically populated
- bbPress plugin: forum lists not showing in correct order? [closed]
- Which file of wordpress manage plugins functionalities?
- How to create an option page for this simple plugin
- Difference and examples of esc_attr__() and esc_attr_e()
- How to set Noindex to all wordpress pages in a catergory?
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- Setup wp_schedule_event within a custom plugin
- Improving the perfomance of a plugin action
- Display Custom Field Value on Admin Page Column
- List the authors that have written posts in a category
- Load Javascript from Plugin in One Page Only?
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- the_tags : can we insert a class
- How to over-ride a file in a plugin? [closed]
- Overwrite category head title
- Plugin is a widget, but I want to call it in the head, can I?
- How to get plugin name from plugin file location
- Check if variable is set in filter
- Cannot get wpdb data (Error in a simple fuction) [closed]
- How to prevent additional code in functions.php to be removed once there is an update?
- WordPress function, Run using Crontab
- Checking the count within a foreach loop
- execute function after one completed
- How to keep variable `$post` to using in another file
- WordPress checkbox and Illegal string offset
- Image change on hover
- Passing stored variables to add_filter
- Create a post builder skin in a plugin
- Plugin Development – Functions or Hooks?
- Proper way to use plugin functions in functions.php
- 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
- How to reset the plugins without deactivate the plugin
- plugins_url() works everywhere but wp_reqister_script()
- JQuery prepend a function
- Basics of changing plugin output
- Adding class to last list item? Not WP generated
- Replacing global wp_query
- Why can’t I call a (member) function from within a foreach?
- Are there action hooks for comments?
- Help with WP Business Directory Manager Plugin?
- Change letters for day name
- I changed .live() to .on() but change is not reflected on the server
- wp_dequeue_script for a Plugin
- Need to replace Currency Shortforms
- wp_enqueue_scripts