Skip Navigation

[Résolu] [wp-if] does not work with CRED

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.

This topic contains 4 réponses, has 2 voix.

Last updated by jamesH-3 Il y a 6 années et 10 mois.

Assigned support staff: Waqas.

Auteur
Publications
#268749

I am trying to ensure:
* admin can submit the form
* users with membership status "Pending" cannot see the submit button
* users with membership status "Confirmed" can see the submit button and submit the form

I used the codes below, however, only the first part for administrator works and second and the third part does not work at all. (they are the same codes I previously used in some of my other views and they are currently working fine. Somehow it does not work with CRED)

[wpv-if evaluate="'[wpv-current-user info="role"]'='administrator'"]

[cred_field field="form_submit" value="Submit" urlparam=""]

[/wpv-if]

[wpv-if membershipstatuscondition="wpcf-membership-status" evaluate="$membershipstatuscondition='Confirmed'"]

[cred_field field="form_submit" value="Submit" urlparam=""]

[/wpv-if]

[wpv-if membershipstatuscondition="wpcf-membership-status" evaluate="$membershipstatuscondition='Pending'"]

You are not allowed to change your business details because your membership is currently pending approval.

[/wpv-if]

Thanks

#269027

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

You can use following alternative syntax also, using direct evaluation:

[wpv-if evaluate="'[types user_meta="membership-status"][/types]' = 'Confirmed'"]
	[cred_field field="form_submit" value="Submit" urlparam=""]
[/wpv-if]

if "membership-status" isn't attached with user account and is a custom field with a post, you can replace [types] short code as below:

[wpv-if evaluate="'[types field="membership-status"][/types]' = 'Confirmed'"]
	[cred_field field="form_submit" value="Submit" urlparam=""]
[/wpv-if]

Please notice the surrounding quotes around the left hand side of the expression, also. This is required when you want to match the string value of field with another string.

On the other hand, please read "Conditional Display for Form Inputs" at https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/ - that offers CRED's built-in feature around this.

#269283

Hi Waqas

"membership-status" is a custom field so I tried:

[wpv-if evaluate="'[wpv-current-user info="role"]'='administrator'"]

[cred_field field="form_submit" value="Submit" urlparam=""]

[/wpv-if]

[wpv-if evaluate="'[types field="membership-status"][/types]'='Confirmed'"]
[cred_field field="form_submit" value="Submit" urlparam=""]
[/wpv-if]

[wpv-if evaluate="'[types field="membership-status"][/types]'='Pending'"]
You are not allowed to change your business details because your membership is currently pending approval.
[/wpv-if]

It's still not working?

Thanks

#269609

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Can you please send me a temporary access to your website? So I can look into the matter and can try to fix it.

I have enabled the private area for your next reply, please input details in that area. Also remember to take a backup of your site.

#269695

Hi Waqas

I worked it out myself mate.

Thanks for your time

Zaf