Home › Toolset Professional Support › [Resolved] Display edit form after logging in
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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)
This topic contains 8 replies, has 2 voices.
Last updated by Minesh 9 months, 3 weeks ago.
Assisted by: Minesh.
I'm trying to set up a page where two different types of users can fill out a form that accomplishes the same goal. One user is already registered and I'd like them to be automatically redirected to edit their form. I don't particularly care if they A) are redirected to the edit form (I can give an example of the edit form page they'd go to), or B) they're redirected to the same page, but the edit form is now accessible.
The problems I'm running into:
- I haven't found a way to create a view that will display the edit form in the loop
- I haven't been able to successfully create a dynamic redirect link based on the post type and the author ID
Those are the two options I've thought could work, but there may be other options I haven't considered. I know there is, of course, a way to create a dynamic edit post link, but it doesn't appear to work in the login form redirect URL. I'm not versed enough in PHP to figure out if there's a way to add a shortcode that gets the author ID and translates that to the post ID so I can use it in the redirect URL or something to that effect, though.
Hello. Thank you for contacting the Toolset support.
As I understand you want to redirect user to edit profile post form automatically once the user is successfully logged in - if that is correct - do you have already created one profile post per user and based on the loggedin user ID that is eventually the post author ID of the profile post and based on that loggedin ID you want to find the profile post whose author is current loggedin user and then redirect user to that specific profile post?
Can you please share bit more details about your current post type structure and how those profiles are managed and I will be able to guide you in the right direction.
Yes, users who will be accessing the login form on this particular page will already have a single post (of this post type) connected to their account as the post author.
The post type is a Speaker Profile and when they log in from the page I'm creating, they would then be automatically redirected to the edit page for their specific post (which is already connected to them via their ID as the author). I have a page where they can view their Speaker Profile and click a button to edit it, but when they log in on this page, the ONLY thing they're intending to do is edit their Speaker Profile, so there's no need for it to do anything else.
Right now, I have had to set it up so that when they log in on this page, they see a button that would redirect them to the edit page, but that's an extraneous step that I'd prefer to eliminate for a smooth user experience.
So ideal flow would be:
User comes to this specific page and logs in
→ The Toolset system pulls the user ID upon login
→ The login form's redirect is able to take that user ID, connect it with the user's Speaker Profile, and insert the post ID into the redirect URL
→ The user is automatically redirected through the Edit Post link upon login
Just let me know if there's more specific info that would be helpful.
you should try to add the following code to "Custom Code" section offered by Toolset (suggested):
- https://toolset.com/documentation/programmer-reference/adding-custom-code/
or
To your current theme's functions.php file
function func_get_edit_profile_id() { $args = array( 'post_type' => 'post-type-slug', 'author' => get_current_user_id(), 'status' => 'publish', 'posts_per_page' => -1, 'fields'=>'ids' ); $user_will = get_posts( $args ); return $user_will[0]; } add_shortcode('get_edit_profile_id', 'func_get_edit_profile_id');
Where:
- Replace 'post-type-slug' with your CPT 'Speaker Profile' slug
Then,
Register the shortcode "get_edit_profile_id" at:
=> Toolset => Settings => Front-end Content => Third-party shortcode arguments
Now, Create a new page that will hold the edit form and add the form shortcode to your page as given under:
[cred_form form='your-edit-form-slug' post='[get_edit_profile_id]']
Where:
- Replace 'your-edit-form-slug' with your original edit form slug.
Then, restrict this page to display with login users only.
- https://toolset.com/course-lesson/restricting-access-to-pages/
I would like to know - are you using toolset login form to display the login form? if yes: Please check the following Doc:
- https://toolset.com/course-lesson/creating-custom-login-forms/#redirect-users-after-they-log-in
Thank you for the function code! I'm not sure if something's still missing, though. I've set it up as you outlined, but when it redirects to the new edit page, it still throws the "Form type and post type do not match" error. My form in the edit page is shown in the screenshot. As far as I can tell, it should be correct. The form is set for Speaker Profile and it works from an edit post shortcode link, so I don't know why it would throw this error.
I have the snippet code set up as shown in the screenshot attached. I've also tried setting it to On Demand and using the specific request parameter to the redirect URL for the login form, but the same error gets thrown. The shortcode I'm trying is shown in a screenshot. The screenshot includes the request parameter, but I've tried it both ways with the same results.
Access control was already set up to only be viewable to users, so that's all set. Is there anything else I could be missing?
Can you please share admin access details so that I can access the backend and see how you setup everything.
Please share where I can see login form as well as on what page you added the edit form and to what page you want to redirect when user login from frontend?
In addition to that please also share the frontend user access details that I should use to check the redirection feature after user login from frontend.
*** 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 have set the next reply to private which means only you and I have access to it.
I see you want to redirect user on the same page.
What if you try to use any of the plugin that serve your need:
- https://wordpress.org/plugins/peters-login-redirect/
- https://wordpress.org/plugins/wp-after-login-redirect-advanced/
I would _prefer_ to be able to redirect to the same page and conditionally display a different form based on whether they already have a Speaker Profile or not, yes. That's where it redirects _new_ users to after they register on that page. You'd recommended redirecting to a separate page with the form editor, though, so that's what I'm currently trying to do. That's what I clearly specified in my last [private] message when I shared the URL for the page it's redirecting to...
Have you tried to use one of the plugin that suits your needs:
- https://wordpress.org/plugins/peters-login-redirect/
- https://wordpress.org/plugins/wp-after-login-redirect-advanced/
On a page - you can display the form using the conditional shortcode or conditional block.
- https://toolset.com/course-lesson/using-toolset-conditional-block/
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/