Home › Toolset Professional Support › [Resolved] child cred forms
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10: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/Kolkata (GMT+05:30)
Related documentation:
This topic contains 9 replies, has 2 voices.
Last updated by Minesh 6 years, 7 months ago.
Assisted by: Minesh.
Hello
I have 2 CPT - User Will, which is parent to Partner Page. I have set the relationship up in the Post Types section.
I then have 2 pages the first is a cred form for User Will then on successful submit we get redirected to the second page where there is a child cred form for Partner Page.
There are 3 things that I'd like to do but have spent days looking through the forums with no workable solution:
1. make the Logged in User have only one User Will
2. Make that User Will only have one Partner Page
3. On the Partner Page cred form the User Will Parent field is not set (i.e it should be related to it's parent in the previous page)
So far I've managed to create the user in a cred form (image 1 - page called 'Sign Up')
Then I've added the user ID to the User Will Cred Form (image 2 - page called 'Who Needs a Will')
Then on submission of the User Will form I have redirected to the page with the Partner Page cred Form (image 3 - page called 'Invite Your Partner') , this is the form where the user-will Parent is not set.
Please can you advise...I'm really desperate now!
Thanks in advance!
Geoff
Hello. Thank you for contacting the Toolset support.
1. make the Logged in User have only one User Will
==> Do you mean that logged in user should be able to create only "ONE" WILL? If user already created will - what you would like to display - redirect to another page?
2. Make that User Will only have one Partner Page
=> Partner page should be accessible only if there is WILL created by user?
3. On the Partner Page cred form the User Will Parent field is not set (i.e it should be related to it's parent in the previous page)
=> I need to check whats going wrong with your setup.
Could you please share problem URL and send me all required details that will help me to understand your issue.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Thanks for sharing the link and brief description about your issue.
However - first of all I would recommend you to update Toolset plugins to it's latest stable release version. I can see the Types plugin version is outdated. Could you please update it.
As I understand :
User will try to login - on successful login - if there is WILL created - we should redirect to partner page - once partner page created - where to redirect?
Could you please share the flow with all conditions so I can check how to satisfy all those conditions.
I have set the next reply to private which means only you and I have access to it.
I think you are not getting what information I want.
As I understand :
User will try to login - on successful login
- if there is WILL created
-- What if user has already created the WILL?
- If WILL is not created user will create the will and we should redirect to partner page - once partner page created:
- where to redirect?
- How many partner pages user can create?
- what if user already has created partner page?
- What happens after partner page is created? where to redirect the user?
Thanks for all required information.
You need to use CRED hook "cred_success_redirect" in order to redirect user to your desired link:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
You need to also use WordPess standard login_redirect hook where after login you should check if the logged-in user:
- If WILL not created - redirect user to WILL page
- if WILL is created but partner page not created - redirect user to partner page
- If both created - redirect user to "user-hub"
More info:
=> https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
Are you able to craft solution on your own OR do you still need help here?
Hi Minesh
Many thanks for responding. I don't think you fully understand what I am asking. I have managed to work out how to do the redirects. What I need to know is how to set up the relationships between:
User
User Will (CPT)
Partner Page (CPT)
I want each User to only have ONE User Will and for that User Will to have ONE Partner Page.
Currently if I go back to the create 'User Will' or 'Create Partner Page' forms they just create a new one so I end up with lots of them and none of them adopt the parent ID through the CRED form.
Many thanks
Geoff
Ok I got it. Well - the thing is that - you can not build relaitonship between users but only with custom post types.
So - What you need to do is - you should have a custom field associated with User Will (CPT) and Partner Page (CPT) that will hold that user ID OR you can make current loggedin user as author of WILL and Partner Page posts.
Now, everything is done within the CRED "cred_success_redirect" and "login_redirect" hook - where you need to fetch the records for WILL and Partner Page.
- If after fresh registration -
(check if any WILL record found) If NO - Redirect user to create WILL page
(check if any WILL record found) If YES - Redirect user to create Partner page
(check if any Partner page record found) If YES - Redirect user to "user-hub"
So - basically, what we are doing is redirecting user to specific page based on record found or not found - so user will not be able to create the new WILL OR Partner page if record found and they should redirected to respective page - if record not found.
Above conditions should be added to "cred_success_redirect" and "login_redirect" hooks respectively.
Now - I can fix this for you but unfortunately FTP access details working but I do not able to see any files or directories. If you need help - please share working FTP access details where I can see files.
Well - you can use code something like this to check if WILL or partner page is exists or not:
global $post; $current_user = wp_get_current_user(); /* checking WILL is exists */ $args = array('post_type' => 'user-will', 'fields' => 'ids', 'meta_query' => array( array( 'key' => 'wpcf-user-id', 'value' => $current_user->ID ), ), ); $will_ids= get_posts($args); /* checking partner pages is exists */ $args = array('post_type' => 'partner-page', 'fields' => 'ids', 'meta_query' => array( array( 'key' => 'wpcf-user-id', 'value' => $current_user->ID ), ), ); $partner_ids= get_posts($args); if(count($will_ids) > 0 and count($partner_ids) > 0 ){ //echo "hi there"."/index.php/user-hub/"; $url = home_url('/index.php/user-hub/'); wp_redirect($url); exit; }else if(empty($will_ids) and empty($partner_ids)){ wp_redirect('index.php/who-needs-a-will/?cred_referrer_form_id=1562' ); exit; }else if(count($will_ids) > 0 and empty($partner_ids)){ wp_redirect('index.php/invite-your-partner/'); exit; }
You should use it with your login_redirect hook or find a way to redirect to your page. I tried to put above code with "wp" hook but the only thing is redirection not working - I dont know why - you should consult some expert for that and hope fully your issue will be resolved.
Hi Minesh
I've applied the code you suggested and now it just gets stuck in a redirect cycle to 'who-needs-a-will' page.. Please can you take a look..I can't access the front end of my site now.
Many thanks
Geoff
That is what I told you that its not working and stuck on redirect - this needs custom thing as I tried to help you as much as I can but this needs expert advise here why redirection is not working.
If you need custom programming for your project, please feel free to consult our certified partners:
=> https://toolset.com/contractors/