Call add_worker() and add_service() functions in Appointments+

Disclaimer: I'm not a developer, but I can read/troubleshoot code.

Plugins: Buddypress & Appointments+

Desired Functionality: I'd like BP users to be able to schedule appointments with each other, but only if they're "friends."

What I think needs to happen (working backwards): To schedule an appointment with each other, all users need to also become service providers. To this end, I would like new users to become service providers at registration (or more specifically after activation of their account).

To accomplish this, on the bp-members-functions.php file (where the registration/activation content lives), I've added a line to include the appointments.php file. When a new user's account is activated, this file sends an email to the site admin to notify them of the new registration. After this line, I've added two more lines:

add_worker( true, $user_id );
add_service( true, 1 );

I've passed 1 as the second parameter for add_service() because I only have one service.

Unfortunately, after I click the link in the registration email to activate my test account, I get an internal server error. When I log in with my admin account, the test user is a registered user, but they don't become a service provider in the Appointments+ Service Provider list as I'd hoped.

(Note: I've also tried $this->add_worker( true, $user_id ); and $this->add_service (true, 1 ); with no luck).

Can anyone show me the error of my ways? I'd be very grateful.

  • aikorei
    • WPMU DEV Initiate

    OK, I decided to just try writing to the app_workers database directly from the functions file. I guess that's probably the easier way. I just figured the add_worker() and add_service() functions may have done other things as well.

    If I'm missing anything, or if anyone has any words of wisdom, I'm all ears.

    Thanks.

  • Hakan
    • The Incredible Smush

    Just a quick note.

    If you say this:

    I'm not a developer, but I can read/troubleshoot code.

    then you cannot do what you want:

    Desired Functionality: I'd like BP users to be able to schedule appointments with each other, but only if they're "friends."

    It is not easy at all.

    We are talking about one of the most sophisticated WordPress plugins. Can you get my point?

    Cheers,
    Hakan

  • aikorei
    • WPMU DEV Initiate

    Thanks for the build up, buttercup. =)

    It's true, I'm not a developer. I don't make a living developing programs, software, or features. But I hope you'll forgive me if I refuse to believe I "can't" do it simply because it's a "sophisticated" plugin and you think it's too difficult for me. It'll take me longer than a real dev, but I'll get there.

    It's not a big deal, though. If I can't find answers here I'll turn elsewhere. To be fair, though, I'm much more interested in paying for a membership to a site that enables me. But I guess that's just the entrepreneur in me speaking.

  • Hakan
    • The Incredible Smush

    But I hope you'll forgive me if I refuse to believe I "can't" do it simply because it's a "sophisticated" plugin and you think it's too difficult for me.

    Ok, difficult not only for you, but for everyone who doesn't know what add_worker and add_service "methods" really do and their structure are.

    Reading a php code may not mean understanding its structure. For example add_worker and add_service are methods (not template functions) inside a class, you cannot simply use them inside your functions.php like this:

    add_worker( true, $user_id );
    add_service( true, 1 );

    or like this:

    $this->add_worker( true, $user_id );
    $this->add_service (true, 1 );

    Please learn more about php classes and we speak later on. Agree?

    Cheers,
    Hakan

  • aikorei
    • WPMU DEV Initiate

    I should probably just let this thread die, but I thought it worth mentioning that I did figure out how to do exactly what I wanted. It took me longer than it should have, because (I repeat) I'm not a developer, but I've managed to auto-add new registered users to the database as service providers AND I've managed to filter service providers by friendship status when scheduling an appointment. I consider this quite an accomplishment considering I couldn't tell the difference between a function and a method (which I was rightly called out on). All I was looking for was a bit of guidance.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.