Skip Navigation

[Resolved] Redirecting user post login to the desired CRED form

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

Problem:

I have a front end page that contains "edit" links in order to encourage contributors to update/amend the information on my site. However, these links for users who arent logged in, point to the login/register page. Id like (if possible) to implement the following functionality.

1. Guest user clicks on EDIT 2. They are sent to the login page 3. They log in, and then are redirected back to the page they were trying to edit in the first place

Solution:

The WordPress built-in login form supports URL parameter "redirect_to", use it you can redirect logged in user to the specific URL, for example:

https://toolset.com/forums/topic/redirecting-user-post-login-to-the-desired-cred-form/#post-914559

Relevant Documentation:

https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect

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.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by johnR-22 3 years, 3 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#914403

Tell us what you are trying to do?
I have a front end page that contains "edit" links in order to encourage contributors to update/amend the information on my site. However, these links for users who arent logged in, point to the login/register page. Id like (if possible) to implement the following functionality.

1. Guest user clicks on EDIT
2. They are sent to the login page
3. They log in, and then are redirected back to the page they were trying to edit in the first place

(Ignore this behaviour for users that arent registered)

Is there any documentation that you are following?

I am currently using the following code which works well (except it doesnt redirect)

<hr />
<p style="text-align: right;">[wpv-conditional if="('[wpv-current-user info='id']' eq '')"]<br />
<a href="<em><u>hidden link</u></em>">edit</a><br />
[/wpv-conditional]</p>
<p style="text-align: right;">[wpv-conditional evaluate="false" if="('[wpv-current-user info='id']' eq '')"]<br />
[toolset-edit-post-link layout_slug="edit-vehicle"]edit[/toolset-edit-post-link]<br />
[/wpv-conditional]</p>
<p style="text-align: right;">

Is there a similar example that we can see?

Im currently working on localhost

What is the link to your site?

localhost, sorry.

#914559

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

The WordPress built-in login form supports URL parameter "redirect_to", use it you can redirect logged in user to the specific URL, for example, you can modify the codes from:

<a href="<em><u>hidden link</u></em>">edit</a>

To:

<a href="<em><u>hidden link</u></em>">edit</a>

And test again,

more help:
https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
$redirect_to
(string) (required) The redirect destination URL.
Default: None

#914766

Thank you Luo, that worked well, BUT (and I apologise I probably could've worded my original question differently) the user needs to land on the actual EDIT page.

So if I click on the edit link on this hidden link

it needs to redirect to hidden link (with 289 being the actual ID)

How can I append the ?layout_id=ID at the end of the URl?

I tried [wpv-layout-id] but that didnt work.

#915068

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You can add the "layout_id=289" into the URL manually, for example:

<a href="<em><u>hidden link</u></em>">edit</a>
#915069

Ah, crap.

Apologies, I assumed the layout_ID changed dynamically between each post.

i've just checked and it doesn't.

DOH!

Thank you Luo.