Service proivers to edit own Working Hours

Hello,

Looking at the screen_content_app_settings() function in the appointments+ plugin I can see that for users using BP they have the option of allowing service providers to edit their own working hours on their profile.

I see you've already added some code and commented in the function that this is for use in the future when we may use this function without BP too.

Is there any chance of letting me know how I can do this now? As I'm in need of this feature but we are not using BP and it's not an option for us to do so at the moment.

Many thanks,
Steven

  • scdwb

    I've made progress using the following:

    add_action( 'admin_menu', array( &$this, 'register_my_custom_submenu_page' ) );
    
    function register_my_custom_submenu_page() {
    
    add_submenu_page(
              'users.php'
            , 'My Hours'
            , 'My Hours'
            , 'unfiltered_html'
            , 'my-break-hours'
            , array( &$this, 'screen_content_app_settings' )
        );
    
    }

    This creates new link in the submenu of the profile link and when clicked the table appears for me to select hours for the service providers. This is great, the problem in any chances to the hours are not saved.

    Can you help?
    Steven

  • scdwb

    Thank you Hakan,

    For some reason the ability for service providers to set working hours does not appear to be working in my non-BP wordpress. I have the setting "Allow Service Provider set working hours" set as Yes.

    Can you pin point me to the function which adds this feature to the profile? I have added a new role (using add_role()) for my providers, so if the plugin checks a specific capability before adding the working hours section to the profile this may be the reason it is not working. Please advise on this and let me know the function in the code so I can check.

    Going back to my code above, where everything seemed to be working but the changes were just not being saved, I have seemed to have solved this using the following:

    add_action( 'init', array( &$this, 'bp_init') );.

    Even though those functions are intended for BP, they still work without BP, because you check against a BP function existing to find the worker ID, and if it doesn't you fall back onto the the global $current_user:

    // In the future we may use this function without BP too
    		if ( function_exists( 'bp_loggedin_user_id') )
    			$user_id = bp_loggedin_user_id();
    		else {
    			global $current_user;
    			$user_id = $current_user->ID;
    		}
  • Hakan

    Can you pin point me to the function which adds this feature to the profile? I have added a new role (using add_role()) for my providers, so if the plugin checks a specific capability before adding the working hours section to the profile this may be the reason it is not working.

    No specific role or capability is required for the provider himself to see and set his own settings, but a 3rd person is required to have 'list_users' capability (which is normally in admin's capability). Maybe they are seeing their settings, but you are not seeing theirs. Add yourself as service provider and check if you can see your own settings, if you aren't already.

    All the user functions are under "user Methods" starting from line 3900.

    Even though those functions are intended for BP, they still work without BP

    It may work, because you are forcing a form intended to be displayed in BP tab to be displayed in another WP page. As BP is a subset of WordPress, it *may* work.

    But we cannot write codes based on "may"s. Working for your case does not mean that it will work for every case. I am responsible for thousands of installations, and I cannot assume that it *may* work. I have to be sure that it *will* work.

    BTW, that comment is for myself and about adding working hour form for the service provider for any WordPress page ans submitting using *front end*. And it requires lots of work to be done.

    On the other hand the functionality you currently require is already included and tested. You may consider checking why it is not working for you. But if you are happy with the current situation, then it is up to you.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.