Skip Navigation

[Résolu] Redirecting user post login to the desired CRED form

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 support ticket is created Il y a 6 années et 6 mois. 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)

Marqué : 

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par johnR-22 Il y a 6 années et 5 mois.

Assisté par: Luo Yang.

Auteur
Publications
#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>lien caché</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

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>lien caché</u></em>">edit</a>

To:

<a href="<em><u>lien caché</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 lien caché

it needs to redirect to lien caché (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

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

<a href="<em><u>lien caché</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.