Are multiple Dummy accounts possible?

Hello,

The idea of a "dummy" account is great! But I'm seemingly limited to only one "dummy" account. I'd like to have multiple dummy accounts; is that possible / something I could hire someone to do?

Thanks!

  • SG Design

    The best way to describe it would be to say that, where Appointments+ allows you to set one "dummy" account to be assigned to multiple "Service Providers", I need the ability to create more than one "dummy" account.

    For example, "dummy user 1" would 'manage' "service provider A" and "service provider B" (this much is currently possible with the uncustomized version of Appointments+). In addition, "dummy user 2" needs to be able to 'manage' "service provider C" and "service provider D".

    I know just enough to think that this would be as easy as replacing the singular "dummy" function(s) with one that uses an array, or something along those lines.

    Could you point me in the right direction as to where I can find the "dummy" code within Appointments+? Or suggest someone I could hire immediately to complete this work for me (I've already posted in the wpmudev "jobs" forum, but to no avail). Thank you!

  • Alexander

    Hi @SG Design,

    I'm sorry for the delay in getting back to you. I'm afraid the only people I could recommend for hire would be the members at our Job Boards.

    I'd like to help point you in the right direction, but in exploring this, I found that it is not going to be an easy task

    If you head to line 702 of appointments.php You'll see the one place that the dummy service provider is actually taken into consideration. This is when we need to get the email for sending a notification. You can make use of the "app_dummy_email" filter, to have a different email address used depending on the worker's ID.

    Unfortunately that's about it. Dummy providers were assigned to delegate back to the admin.

    Here's the challenge: The appointments are still truly assigned to the dummy provider who has a separate ID. The code checks to make sure the logged in user has the same ID. Because we can never be logged in as this dummy, nobody will ever have the dummy's appointments under "My appointments"

    The table where providers can manage their appointments is always generated using the [app_my_appointments] shortcode - even when shown in on their profile in the Dashboard.

    The code for this shortcode can be found in includes/class_app_shortcodes.php. Take a look at line 847 and you'll see the SQL query that retrieves the appointments to be shown. I have not tried this, as it would take quite a bit of customizing (more than can be offered with support) but I suspect that modifying this query to include multiple worker IDs would be the best place to start.

    Hope this helps!

    Best regards,

    Best regards,

  • SG Design

    I think the best method will be to customize the plugin so anyone who can view a list of appointments can also cancel them. Any idea his best to do that?

    I essentially want to remove the "is_owner" check that prevents one user from seeing or canceling the appointments of another user. Because the short code has options --- "provider" and "provider_id" --- I think I can remove the "My Appointments" tab from the BuddyPress profile, and instead create a page for each user, using the my_appoinements shortcode + provider_id. Assuming the permission checks have been eliminated, that should work, I think... Your thoughts?

    Thanks again!

  • Alexander

    Hi @SG Design,

    I'm sorry for missing your next response. I've checked back on this for you and foudn something else. I've not tried this, but around the code same area I mentioned earlier (class_app_shortcodes.php line 847) you'll also see the checks for if the user is the specified worker or not. A variable called $allow_confirm will be set based on that condition. You can try changing the condition to one of your own that would allow appointments to be confirmed. The same can be done for canceling with $a_cancel a few lines later.

    Best regards,

  • SG Design

    Alexander,

    Thank you for the great tips!

    I was able to create a page template and have it load shortcode like this:
    [app_my_appointments provider=1 provider_id=5 _allow_confirm=1 status=pending]

    Then I modified appointments.php around lines 2469 to permit my special users to confirm for other users (i.e. I fixed that "You don't have the authority to do this" error).
    Like this:

    if ( current_user_can('custom_manageappts') );
    		 elseif ( !$user_id || !wp_verify_nonce($_POST['app_bp_settings_submit'],'app_bp_settings_submit')
    				|| $user_id != $_POST["app_bp_settings_user"] || !$this->is_worker( $user_id )
    				|| !isset( $this->options["allow_worker_wh"] ) || 'yes' != $this->options["allow_worker_wh"] ) {
    			wp_die( 'You don\'t have the authority to do this.', 'appointments' );
    			exit;
    		}

    This will allow a user with the "custom_manageappts" capability to see and check the "confirm" box when the above shortcode is displayed.

    HOWEVER....When the user ticks the "Confirm" checkbox and clicks "Submit", the changes are not submitted.

    I assume the confirmation is being prevented by either another permissions check, or, what I think is more likely, is that the plugin is trying to confirm the appointment for the current user ID instead of the provider ID given in the shortcode argument (provider_id=5).

    Do you have any idea what I could be missing that would prevent one user from confirming the appointment of another user?

    I wondered about this ~ line 3477 of appointments.php:

    // Checks are ok, let's save settings.
    		$this->save_profile( $user_id );
    	}

    If it's not that, the other place I wondered about is in appointments.php around line 3189 to 3266, in the area of this code:

    // Only user who is a worker can save the rest
    		if ( current_user_can('custom_manageappts') ) //here is my custom code
    			return;
    		 elseif ( !$this->is_worker( $profileuser_id ) )
    			return;
    
    		// Confirm an appointment using profile page
    		if ( isset( $_POST['app_confirm'] ) && is_array( $_POST['app_confirm'] ) && !empty( $_POST['app_confirm'] ) ) {
    			foreach ( $_POST['app_confirm'] as $app_id=>$value ) {
    				if ( $this->change_status( 'confirmed', $app_id ) ) {
    					$this->log( sprintf( __('Service Provider %s manually confirmed appointment with ID: %s','appointments'), $this->get_worker_name( $current_user->ID ), $app_id ) );
    					$this->send_confirmation( $app_id );
    				}
    			}
    		}

    Any thoughts/ideas/suggestions would be greatly appreciated! Thanks again!

  • Alexander

    Hi @SG Design,

    Are you using BuddyPress? Most of the code you're referring to handles in the bp_init action which only runs if you're using BuddyPress.

    I believe the actual confirmation takes place in the save_profile function, around line 3193

    This runs whenever a user saves their profile.
    if ( $this->change_status( 'confirmed', $app_id ) ) {

    From what I can tell, it doesn't run anywhere else. This means that while your shortcode has controls for the form, nothing is handling the actual form submission. You can try using the code within the save profile function and adapting it to happen within the shortcode.

    Best regards,

  • SG Design

    Update... I tried everything I could think of to make this work. I can check the "confirm" box but the changes don't save and the appointment remains as "Pending"

    In my testing example, I have a client we'll call "Client" (user_id = 4). The Service Provider we'll call "Provider" (provider_id=5 // user_id=5).

    In class_app_shortcodes.php on line 964, I changed the code to specify the user_id of the provider whose appointment I'm trying to confirm, like this:

    <input type="hidden" name="app_bp_settings_user" value="5">';
    (I specified "5" [provider's user_id] instead of "'. $bp->displayed_user->id .'")

    And I also tried commenting-out the line below it: wp_nonce_field('app_bp_settings_submit','app_bp_settings_submit', true, false );

    Additionally, in appointments.php, on lines 3463, I changed the code as follows:

    if ( function_exists( 'bp_loggedin_user_id') )
    			$user_id = "5";
    		else {
    			global $current_user;
    			$user_id = "5";

    And I even tried the same thing on line 3478 like this:

    // Checks are ok, let's save settings.
    		$this->save_profile( "5" );

    Is there something I'm missing? Why wouldn't that allow me to manually confirm the appointment for the provider with user_id "5"? And, is there any feasible way for me to debug this, such that I could see why the code is simply returning without submitting my appointment confirmation?

    Thanks again!

  • Alexander

    Hi @SG Design,

    I'm really not quite sure at this point. As none of this was intended to be possible by the plugin, I'm afraid it might take a but more reworking. But after looking at this I'm not quite sure where to look next.

    It may not be possible, but I am going to bring this thread to the attention of the developer for you. Maybe he can look at your code and offer some insight.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.