• Resolved Ja4ed

    (@ja4ed)


    I set a user’s Out of Office setting to Yes, check the Out of Office expiry checkbox and enter an expiry date. The out of office widget displays the correct information.
    On the expiry date, the user’s Out of Office setting is changed to No, but the out of office widget still the displays the user and the expiry date. I have to manually uncheck the Out of Office expiry checkbox to remove the user from the out of office widget.
    Can you make a change so the user is no longer displayed in the Out of Office widget on the expiry date. It seems like all it would take is some additional code to uncheck the Out of Office expiry checkbox on the expiry date?

    https://wordpress.org/plugins/simple-intranet-directory/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Chris

    (@charlwood)

    All functions fine when I test. It could be an issue with your server and WordPress timezone settings. Try playing with that. When I set the Out of Office expiry date to today (logged in as an Admin, editing a Your Profile user), the widget dissappears and the pull down setting of “Out of Office?” is reset to No when the profile is saved/updated.

    Here is the function that deals with this. You may want to try uncommenting the timezone related options and see if that helps your issue. Just be sure to set your timezone in your Settings/General area I believe.

    function outofoffice_check() {
    
    global $in_out, $officeexpire, $current_user;
    //$gofs = get_option( 'gmt_offset' ); // get WordPress offset in hours
    //$tz = date_default_timezone_get(); // get current PHP timezone
    //date_default_timezone_set('Etc/GMT'.(($gofs < 0)?'+':'').-$gofs);
    // set the PHP timezone to match WordPress
    	$right_now=time();
    	  foreach ($authors9 as $key =>$author9 ) {
    
    	 $in_out=  get_the_author_meta( 'si_office_status', $author9, true) ;
    	 $officeexpire= get_the_author_meta( 'officeexpire_unix', $author9 ) ;
    	 $set_expiry= esc_attr( get_the_author_meta( 'expiry', $author9 ) ); 	
    
    	 if($set_expiry=="Yes"){
    	 if($officeexpire<=$right_now ){
    	 $in_out='false';
    	 update_user_meta($author9, 'si_office_status','false');
    	 }
    	 if($officeexpire>=$right_now ){
    	 $in_out='true';
    	 update_user_meta($author9, 'si_office_status','true');
    	  }
    	  }
    	  }
    //  date_default_timezone_set($tz); // set the PHP timezone back the way it was
    }
    Plugin Author Chris

    (@charlwood)

    I’m going to mark this as resolved as I haven’t heard back in a few days and I think the above answer will help you solve the issue.

    Thread Starter Ja4ed

    (@ja4ed)

    I know it’s been awhile, but I’ve been working with this and I think I know what’s going on.

    If I set a user as out of office and set the expire date in the future, the user appears in the out of office widget correctly. If I then change the expire date to today and update the user, the user no longer appears in the out of office widget. This is correct.

    But, if I set a user as out of office, set the expire date in the future, and do nothing, the user appears in the out of office widget even after the expire date. After the expire date, if I click the Update User button for this user, the user no longer appears in the out of office widget.

    It seems like the widget is not checking the out of office setting automatically. Only when the user is updated.

    Thread Starter Ja4ed

    (@ja4ed)

    Forgot to mention that I have uncommented all the timezone options, but that made no difference. Thanks.

    Plugin Author Chris

    (@charlwood)

    Ah yes… I’ll recheck this. There is a php cron function to check this function regularly that some servers may not support (or old PHP versions)… I’ll recheck this to see if it is working for me, but what PHP version are you using so that I can be sure that is not the issue? 5.3 and better is ideal.

    Thread Starter Ja4ed

    (@ja4ed)

    Using PHP 5.3.4

    Plugin Author Chris

    (@charlwood)

    OK, just issued a version 2.8 which fixes a wrongly reference function and uses WP’s current_time() function instead of PHP time() function which now adjusts for timezones set in WP.

    Thread Starter Ja4ed

    (@ja4ed)

    After installing version 2.8 (actually installed version 2.8 and then 2.9), I tested this the past two days and the problem persists

    Plugin Author Chris

    (@charlwood)

    Huh…. worked in my tests… I’ll see what else it could be… possibly still a timezone issue, or some PHP installs may not support the chron process.

    Plugin Author Chris

    (@charlwood)

    OK, try version 3.0 just issued… hopefully that’ll work for you. πŸ™‚

    Thread Starter Ja4ed

    (@ja4ed)

    Still not working. I wonder if one of my other plugins is causing an issue with the timezone. I’m using CalPress Calendar and it forces me to use the Chicago timezone instead of UTC-5. Could that be causing a problem?

    Plugin Author Chris

    (@charlwood)

    Are you using version 3.1? It works on my tests… yes, if the timezone setting is out, that will cause issues. We use the current_time() function to sync with WP timezone settings.

    Thread Starter Ja4ed

    (@ja4ed)

    Yes, using version 3.1. I tested the current_time() function and it returns the correct date/time.

    I think that section of code is working correctly as written. Because when I look at the MySQL wp_usermeta table, the si_office_status key has the correct true/false value both before and after the expiry time.

    But, it appears that the widget doesn’t read that key (and subsequently display the correct out of office status) until I press the Update Profile button in the WordPress user profile.

    The ‘out of the office WIDGET’ section of code may be where the problem lies. How often is that section of code run? It doesn’t look as if it’s on a schedule like the hourly check.

    Plugin Author Chris

    (@charlwood)

    No, there’s no scheduled check on the widget itself… that is a possibility I suppose, but it will could hurt performance. I’ll consider that for sure. I know that if you load the [employees] directory shortcode page and refresh say twice, it should refresh all user profile data and does update the widgets. Widgets in WordPress seem to have their own kind of cache, and can be delayed when updated…

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Out of Office widget – expiry’ is closed to new replies.