Skip Navigation

[Resolved] Notify authors of repeatable field groups, after CRED (Edit) Form Post is submit

This support ticket is created 3 years, 8 months 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.

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)

This topic contains 10 replies, has 2 voices.

Last updated by Lara 3 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1726811
2020-08-04_Toolset-Bywood-Not_Broke.PNG
2020-08-04_Toolset-Bywood-Broke.PNG

Tell us what you are trying to do?

I have a post type "A". This post typ has a repeatable field group. The repeatable field group contains the name of a person and a email adress. After the CRED edit Form is submitted, everyone should receive an email, except this person ..

[wpv-attribute name="email_interessent"]

For this purpose, I created a view, which creates an array with the email adresses..

View:

[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-conditional if='( $(wpcf-e-mail_interessent) ne "[wpv-attribute name="auserwahlter_interessent"]" )'][types field='e-mail_interessent' output='raw'][/types]  ,  [/wpv-conditional] </wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found][/wpv-no-items-found][wpv-layout-end]

After that I inserted the view into the single line field of the following CRED (Edit) Form ...

CRED (Edit) Form:
(I removed all other cred_fields from the form for better readability)

[credform]
[cred_field field="e-mail-adressen-nichtausgewaehlte-bieter" force_type="field" class="form-control" output="bootstrap" value='[wpv-view name="e-mail-adressen-childposts" auserwahlter_interessent="[wpv-attribute name="email_interessent"]"]' ]
[/credform]

The problem:

[php]
[credform]
[cred_field field="e-mail-adressen-nichtausgewaehlte-bieter" force_type="field" class="form-control" output="bootstrap" value='[wpv-view name="e-mail-adressen-childposts"]' ]
[/credform]
[php]

..... this works perfectly fine, but as soon as I insert ...

[wpv-attribute name="email_interessent"]

... into the view like this ..

[php]
[credform]
[cred_field field="e-mail-adressen-nichtausgewaehlte-bieter" force_type="field" class="form-control" output="bootstrap" value='[wpv-view name="e-mail-adressen-childposts" auserwahlter_interessent="[wpv-attribute name="email_interessent"]"]' ]
[/credform]
[php]

... it breaks. It seems like there are too many '' and "" in it 🙂
Any suggestions or ideas, what could be changed to make it work?

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your site?
hidden link

#1727247

Nigel
Supporter

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

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

Hi Lara

I'm not sure you are trying to use wpv-attribute correctly. I don't quite follow the details of what you are trying to do, but [wpv-view name="e-mail-adressen-childposts" auserwahlter_interessent="[wpv-attribute name="email_interessent"]"] is wrong.

You use wpv-attribute inside a View to access a value that was passed to the View.

It looks like you are trying to use wpv-attribute to pass a value to the View, but that's not how it works.

If I wanted to pass a country to a View I could do it like this, for example:

[wpv-view name="country-view" country="Italy"]

Then, inside the View itself in the output section you can refer to the passed value by using the wpv-attribute shortcode, so

[wpv-attribute param='country']

would output "Italy" in this example.

You may also pass dynamic values, e.g.

[wpv-view name="country-view" country="[wpv-post-title]"]

which would pass the current post title, or maybe you would pass the value from some custom field etc.

Does that help you with your use case?

If not, I'll need to get some more details about what the objective is.

#1727637

Hi Nigel,

it's kind of complicated. The posttyp A is something like a product / an offer. The client wants a plattform, where people can sell wood. Posttyp A represents the wood. Furthermore the client wants, that the plattform users can negotiate about the wood. So, the person, who owns the wood, can negotiate with other people about his wood simultaneously - and no one besides the owner of the wood should know with how many people he is negotiating currently. I created each negotiation as a repeatable group field of posttyp A (the product / offer / wood). The negotation starts as soon as someone creates a new repeatable group field through a CRED form. After that, they can negotiate through using two different CRED (Edit) Forms - each CRED (Edit) Form can change the repeatable field group. For example CRED (Edit) Form 1 represents the owner of the wood. If this Form is submitted, a select field in the repeatable field group, will have the value 1 (owner), if the other CRED (Edit) Form is submitted the same select field will have the value 2 (negotiating partner). If the owner of the wood, decides to sell the wood to one of his negotiating partners, the post type A (product / offer / wood) needs to change its status (select field) to sold.

1. There is the page
2. Inside the page is a View that loads the userpost of the current user
3. Inside View 2 there is another view, that loads all negotiations, in which the current user is involved
4. Inside View 3 there need to be a CRED (Edit) Form, that changes Post Typ A (product / offer / wood), as soon as someone buys it. This isn't possible, because CRED (Edit) Forms can only be executed in posttypes the belong to. So, I wrapped the CRED (Edit) Form in a View that loads Posttype A. Also, this CRED (Edit) Form contains the email_field in which I load the email_adresses of all negotiation partners.

One day I accidently figured out, that it is possible to pass an argument through different nested views with the "wpv-attribute". Let me explain...

The CRED (Edit Posttyp A) Form also needs to contain values of the "Repeatable Field Group" Post - for example the negotiated price. Because Posttyp A and the Repeatable Field Group Post are a one-to-many-relationship this is not possible. It will always output the values of the first Repeatable Field Group Post. Therefore I pass the value ....

[wpv-view name="negotiation_parent" negotiated_price_a="[types price_field]" email_interessent_a="[types email_field]"]

than I can access it in the CRED (Edit) Form with..

[wpv-attribute name="negotiated_price_a"]
[wpv-attribute name="email_interessent_a"]

... or I can pass it on into another view inside this view, like that ...

[wpv-view name="view_inside_negotiation_parent_view" negotiated_price_b='[wpv-attribute name="negotiated_price_a"]' email_interessent_b='[wpv-attribute name="email_interessent_a"]']

Inside this view I can access the values as ...

[wpv-attribute name="negotiated_price_b"]
[wpv-attribute name="email_interessent_b"]

To sum up, yes I was serious about ...

[credform]
[cred_field field="e-mail-adressen-nichtausgewaehlte-bieter" force_type="field" class="form-control" output="bootstrap" value='[wpv-view name="e-mail-adressen-childposts" auserwahlter_interessent="[wpv-attribute name="email_interessent"]"]' ]
[/credform]
#1727973

Nigel
Supporter

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

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

OK, that's pretty complicated!

You thought the problem was related to the quote marks: you effectively need single quotes, double quotes, and some non-existant triple quotes.

Before I dig too deeply into your setup, did you try switching the quotes for the final wpv-attribute shortcode argument, to use single quotes?

So the value attribute of the cred_field shortcode would become

    value='[wpv-view 
                name="e-mail-adressen-childposts" 
                auserwahlter_interessent="[wpv-attribute name='email_interessent']"
            ]'

That could work if the wpv-view shortcode is parsed before the cred_field shortcode, the only way to be sure is to try it and see.

Otherwise a solution could be to create a custom shortcode that essentially does the same as the wpv-attribute shortcode but without the need to specify the param attribute (because it is hard-coded into the shortcode already).

Something like...

add_shortcode( 'email_interessent', function(){

    $output = do_shortcode("[wpv-attribute name='email_interessent']");

    return $output;
});

Then replace the actual wpv-attribute shortcode call with the custom shortcode, e.g.

    value='[wpv-view 
                name="e-mail-adressen-childposts" 
                auserwahlter_interessent="[email_interessent]"
            ]'

(You would need to register the custom shortcode at Toolset > Settings > Front-end Content.)

#1728201

Many thanks Nigel 🙂 I like your suggestions.
Right now, I am stuck with some other work, but I will try to test it in the evening
and update you accordingly.

Thanks ...

#1729025

Nigel
Supporter

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

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

Let me know how you get on and if you need further help.

#1729373

Hi Nigel,
I am truely sorry for the delay.
My work colleague, who is involved in that project too, slowed the process of testing down.
As I don't have access to the accounts with whom we ususally test the negotiating,
I need to wait for her action to progess further.

I will update you as soon as possible regarding this topic.

Kind regards
Lara

#1729383

Nigel
Supporter

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

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

Not a problem at all, I'll just mark this as awaiting your feedback so that it doesn't sit in my queue.

#1729421

So, I got access ... and here we go 🙂 :

value='[wpv-view 
            name="e-mail-adressen-childposts"
            auserwahlter_interessent="[wpv-attribute name='email_interessent']"
        ]'

... works 🙂 🙂 🙂 But only as long as I don't change the shape of the code. For example ..

value='[wpv-view name="e-mail-adressen-childposts" auserwahlter_interessent="[wpv-attribute name='email_interessent']"]'

... doesn't work. Although the content is the same. Anyway I am happy. We will use ...

value='[wpv-view 
            name="e-mail-adressen-childposts"
            auserwahlter_interessent="[wpv-attribute name='email_interessent']"
        ]'

... and I made a note/comment in the code, that under no circumstances shape of the code should be changed.

A have a last additional question. Do you know, if the CRED single text field has a character limit ?

Kind regards
Lara

#1729445

Nigel
Supporter

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

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

That's very odd, I only formatted it like that to make it easier to read and see how the wrapping with quotes worked, but I'm glad to know it works, anyway.

Regarding the character limit, there is no hard-coded limit, it depends on the database. The data is stored in the wp_postmeta table in the meta_value column, which is a LONGTEXT type. That can store up to 4Gb of data in a single entry. How many characters that translates to depends on your character encoding and the characters themselves (some of which may be stored as single bytes, others up to 4 bytes for utf8mb4 encoding, for example). In practical terms, it's a very large number of characters, which is not fixed.

#1729617

Yes, I agree with you, it's very odd. I tried the version with the shortcode, too. It was the same.

This ...

value='[wpv-view 
            name="e-mail-adressen-childposts"
            auserwahlter_interessent="[email_interessent]"
        ]'

... works and this ...

value='[wpv-view  name="e-mail-adressen-childposts" auserwahlter_interessent="[email_interessent]"]'

... doesn't work.

Anyway, I am glad, that you formatted it like that 🙂 and also that I was too lazy to write it myself and copied and pasted instead 😉

Regarding the character issue, 4 GB should be enough. Many thanks Nigel.

--- This issue is solved. ----

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