Skip Navigation

[Resolved] Set the post author when payment completes

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.30 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Author
Posts
#1211864
Capture.PNG

Hi guys good day!

I am trying to:

I'm trying to create form for a product (sponsorship article) with front-end submission with payment.

I've created the form (for creating a sponsorship post) and created a custom role (sponsor) through the access plugin. The reason is that I want to target different roles differently through clear segmentation.

Woocommerce has "customer" as role and Form has "default" or "author" as roles. Now, according to this scenario, I'm limited to choose the role of this product to either author or customer. So there is still a mismatch between the custom role (sponsor) I've created with access and the options presented by form commerce or woocommerce.

Unfortunately, when I reached: (Set the post author when payment completes)

Question:
It is not possible to choose from a dropdown or a list my created custom role (sponsor) for this specific "product" instead of this (After payment completes, make the client the author of the post)

If this is not possible at this moment, how can this be achieved programmatically? Do you have any idea how this can be achieved?

Would you consider this option to be implemented soon?

See screen

I look forward to hear back from you asap

Best regards,

#1211904

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

I'm not sure I understand your question.

First let me point out that we have a known issue with user forms in a similar scenario: https://toolset.com/errata/notification-email-is-not-sent-when-completing-an-order-created-by-toolset-forms-commerce/

If your problem is that you have set up post forms to do the same and it is simply not working, then I can test that.

The title of your question is about setting the post author when payment status completes, have you tried that and it is not working?

You write about custom roles, but I'm missing the relevance of this in this particular scenario, if you could elaborate.

Btw, you will be pleased to learn that support for multiple roles is coming soon to Access. In the initial update there will be support for Access rules where users have multiple roles, to cover where other plugins (such as WC Subscriptions) add a role. A subsequent update will also let you set multiple roles within Access itself.

#1212043
Capture3.PNG
Capture1.PNG

Hi again

My question was simply to be able to set a different role than the one mentioned in the setting of the Edit Form (see screen)

"After payment completes, make the client the author of the post". I want the customer of this product assigned the "sponsor" role that I created with Access

Because, I created a custom role with Access (see screen). And I want after payment completes, make the client the "sponsor" of the post.

I hope it is now clear

Regarding you other questions, I spent a whole day testing but as you mentioned it's useless unless the notification issue with forms commerce is solved which I hope as soon as possible to be able to continue the implementation and test the whole purchase process, see the notification coming and see the whole process in action.

Now the status now is as follow

Edit form: puts the product in cart and redirects to a not found page. Then when I go to cart to proceed with order, I must be logged to check out

hidden link

User form: when I submit the form, it redirects back to the same form, although I set it up for purchasing a product.

hidden link

I followed the guides below for setting up the forms and woocommerce

https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/

https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/

#1212658

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2019-03-11 at 14.47.10.png

Toolset Forms Commerce serves two purposes, but it sounds like you want a hybrid of the two.

You can use it to charge users to publish content (built on the back of post forms), or you can use it to charge users to register on the site (built on the back of user forms).

When you charge users to register, the form specifies the role they will be given when the process, including payment, completes. Custom roles are available (see screenshot).

But your screenshots and description are of a post form, used to charge users to publish content. There is no place for roles here. What changes as the order progresses through to payment is the status of the post being published. You can optionally specify who the author of the published post will be.

It sounds like you want to update the latter workflow so that not only is the post published when the order completes, but the role of the author of the post is changed to your custom role at the same time.

That's not something which is envisaged, and so would require custom code to set up.

You would use the Forms Commerce API hook cred_commerce_after_order_completed. See https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_order_completed

That hook will be triggered when the order status is marked as complete.

You have the user id available in the $data argument.

You can use a function such as wp_update_user to modify the role of an existing user (https://codex.wordpress.org/Function_Reference/wp_update_user).

Is that what you are aiming for? A form to charge payment to publish content which changes the role of the user after payment completes?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.