Skip Navigation

[Resolved] User created before payment made creates loophole.

This thread is resolved. Here is a description of the problem and solution.

Problem:
Q1) Create user with CRED form, activate the user after he make the payment
Q2) The username/email they are trying to register with will return an error because the email/username has already been used
Q3) check if post author of current post is an activated wordpress user
Solution:
A1) With CRED commerce plugin, you can download it here:
https://toolset.com/account/downloads/
Then you will be able to setup it as hidden user after submit the form, activate the user after they make the payment
A2) If you use above suggestion, then the new user will be able to created only after they make the payment, so there will not be such a problem.
A3) Use Views shortcode wpv–conditional to check if the author of current post

[wpv–conditional if="''='[wpv-post-author format="meta" meta="user_login"]'"]
    ----------No-----------> Don't display post
[/wpv–conditional]
[wpv–conditional if="''!='[wpv-post-author format="meta" meta="user_login"]'"]
Display Business Listing
[/wpv–conditional]

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

This support ticket is created 8 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by jamesH-10 8 years ago.

Assisted by: Luo Yang.

Author
Posts
#378442

I am trying to: set up a paid membership site.

I created a CRED form and product as per the tutorial below. I found that the user is created on submission of the form and prior to the payment being processed which means that they are able to login before they have paid. I have seen at the bottom of the CRED form that they are hidden until the payment has been processed.

Once a member has paid they are allowed to create a business listing. I have some conditional logic on the page to make sure they are logged in:

[wpv-if evaluate="'[wpv-current-user info="logged_in"]' = 'true'"]
[cred_form form="Add Listing"]
[/wpv-if]
[wpv-if evaluate="'[wpv-current-user info="logged_in"]' = 'false'"]
You must be a member to create a business listing.
[cred_user_form form="Silver Membership Form"]
[/wpv-if]

However, when viewing the page and they have logged in using this 'loophole' I'd like to be able to test to see if the user is hidden ( ie their account hasn't been processed following payment ) or not and then use the same kind of logic as mentioned above.

The next issue with the way this works is that if the sign up process fails in anyway then the username/email they are trying to register with will return an error because the email/username has already been used.

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

I can provide URLs via private message if required.

Many thanks,
Chris.

#378537

Dear Chris,

Q1) loophole
This is expected result, the CRED form for creating user will create a wordpress user after submit the form.
And I see you are using woocommerce plugin + CRED, I suggest you try our CRED commerce plugin, you can download it here:
https://toolset.com/account/downloads/
Then you will be able to setup it as hidden user after submit the form, activate the user after they make the payment, see our document:
https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/
section "3. Setting the CRED Commerce options to charge for registration"
screenshot:
https://toolset.com/wp-content/uploads/2016/01/cred-commerce-user-statuses.jpg
Optionally, you can change the status of the user, depending on the current payment status.
There are three user creation statuses:

Hide the user: User information is still stored in the database but not yet published; it is visible in the site
Delete the user: User information is deleted from the database and the site
Create user: The user is created and published in the site

Q2) the username/email they are trying to register with will return an error because the email/username has already been used
If you use above suggestion, then the new user will be able to created only after they make the payment, so there will not be such a problem.

#378545

Hi Luoy,

Thanks for the quick response.

Next question is how can I test if a user is hidden or active? That doesn't seem to be an option for wpv-current-user. It's be great if there was a way to add that this shortcode so that I can display the relevant content to prompt the user to make a payment.

I am using CRED Commerce, just didn't mention in original post.

Is there some PHP that I could use to test this and use it in a page template or; is it possible to add that test to wpv-current-user by modifying the plugin?

Thanks again,
Chris

#378752

You are right, since the user does not login wordpress, and he/she isn't a wordpress user too, there isn't anyway to test if the user is a hidden user, but you can use wpv-current-user to check if current user is active user, see our docuement:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

section "Checking For The Current User Data"

#380793

Thanks Luoy,

I just want to be clear here about my intentions. I want to test if the user who created a post has an active account and if so display there posts. If not don't display posts.

So a flowchart would look like:

Get Business Listings
( custom post types )
|
|
^
< Is Post Author > ----------No-----------> Don't display post
Active Member?
V
|
|
Yes
|
|
V

Display Business Listing

I am happy to write my own PHP to make this happen but I need to know what hooks or filters can be used to make this happen.

Many thanks,
Chris

#380841

Are you going to check if current logged in user is the author of current post?
If it is, you can use [wpv-conditional] shortcode, like this:

[wpv–conditional if="'[wpv-current-user info="login"]'='[wpv-post-author format="meta" meta="user_login"]'"]
Display Business Listing
[/wpv–conditional]
[wpv–conditional if="'[wpv-current-user info="login"]'!='[wpv-post-author format="meta" meta="user_login"]'"]
    ----------No-----------> Don't display post
[/wpv–conditional]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional

#380880

No I need to know if the person who made the post has an active account.

When they sign up they make can a business listing (CPT). I need to display that post only when the user has an active membership. When their membership expires I need to change it to not display.

This is all independent of the current user.

#381150

Sorry for the misunderstandm.
I assume you are going to check if post author of current post is an activated wordpress user, you can try this:

[wpv–conditional if="''='[wpv-post-author format="meta" meta="user_login"]'"]
    ----------No-----------> Don't display post
[/wpv–conditional]
[wpv–conditional if="''!='[wpv-post-author format="meta" meta="user_login"]'"]
Display Business Listing
[/wpv–conditional]
#381695

HI Luoy,

Thanks for that. It helped me to get to where I needed to get. I will clarify what I ended up using to help anyone else who wants to achieve the same thing.

[wpv-if evaluate="'[wpv-post-author format="meta" meta="user_level"]'!='10'"]
    ----------No-----------> Don't display post
[/wpv-if]
[wpv-if evaluate="'[wpv-post-author format="meta" meta="user_level"]'='10'"]
Display Business Listing
[/wpv-if]

The meta data is attached to all users and contains numerous attributes that you can see more of here: http://codex.wordpress.org/Function_Reference/the_author_meta

The number 10 is simply the user_level or role of the posts author ( like administrator or editor - I created my own user levels ).

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