Saltar navegación

[Resuelto] Redirect after login

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

I've added a view to a page so that when an unlogged in user attempts to click on a PDF download within that view/grid, it takes them to a login page. After they login, it takes them to an account page basically. But what I need it to do, is instead, after logging in, for it to take them right to the PDF that they clicked on initially, or back to that same page where they found the PDF on in the first place:)

Solution:

If it is a login from setup by Views shortcode [wpv-login-form], then it is possible to setup the redirect URL with shortcode attribute "redirect_url".

See details here:

https://toolset.com/forums/topic/redirect-after-login-3/#post-1153603

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-login-form

This support ticket is created hace 6 años, 1 mes. 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)

Etiquetado: 

Este tema contiene 16 respuestas, tiene 2 mensajes.

Última actualización por Jas hace 6 años, 1 mes.

Asistido por: Luo Yang.

Autor
Mensajes
#1153588

Jas

Hi Lou Yang, I've added a view to a page so that when an unlogged in user attempts to click on a PDF download within that view/grid, it takes them to a login page. After they login, it takes them to an account page basically. But what I need it to do, is instead, after logging in, for it to take them right to the PDF that they clicked on initially, or back to that same page where they found the PDF on in the first place:)

I know I"m missing the part where I tell it where to go after logging in, but don't know what to add to the view to achieve this.

Much thanks in advance!! 🙂

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<div class="col-md-4">

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
<p>[wpv-post-featured-image size="medium"]</p>
<h4>[wpv-post-title]</h4>
[wpv-post-body view_template="None"]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
<p>enlace oculto">[wpv-post-featured-image size="medium"]</p>
<h4>enlace oculto">[wpv-post-title]</h4>
[wpv-post-body view_template="None"]
[/wpv-conditional]

</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

#1153603

Hello,

How do you setup the login form in the URL "enlace oculto" ?

If it is a login from setup by Views shortcode [wpv-login-form], then it is possible to setup the redirect URL with shortcode attribute "redirect_url".

For example:
1) Edit the view you mentioned above, change this line from:

<p><a href="<em><u>enlace oculto</u></em>">[wpv-post-featured-image size="medium"]</a></p>

To:

<p><a href="<em><u>enlace oculto</u></em>">[wpv-post-featured-image size="medium"]</a></p>

It will pass current post URL as an URL parameter "redirect_to"

In the login page, you can get the URL with shortcode [wpv-search-term], like this:
[wpv-search-term param="redirect_to"]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term

And use it in the shortcode [wpv-login-form], like this:

[wpv-login-form redirect_url='[wpv-search-term param="redirect_to"]']

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-login-form
redirect_url (opt):
An absolute URL
If redirect_url attribute is set, visitors will be redirected to the specified URL.

#1153616

Jas

Ok, unfortunately, I was recommended to use the Divi builders login module to build the login form (against my better judgment), as I don't know CSS etc., but what If I replaced that login module with a code module and put the toolset shortcode into that. would that work? (everything else is perfectly set up (which took me forever as a beginner, so I hate to wreck what's been finally figured out).

#1153619

Yes, it should be able to work, you can test it and feedback if there is any problem.

#1153642

Jas

Ok I think I understand the concept of the first half. the two links you sent both are not displaying in my browser fully for some reason. I understand needing to change the "enlace oculto;
but, but still don't understand what comes after that (and like I say, can't read docs pages properly (they are cut in half vertically). I need it to open to the page they were on before login, or directly to a document if they clicked one.

#1153650

Please provide a test site with the same problem, also point out the problem page URL, I can setup a demo for you.

For the new problem:

can't read docs pages properly (they are cut in half vertically)

It is abnormal, I suggest you try another browser, for example: Google Chrome, Microsoft Edge
If the problem still persists, please create a new thread for it.

#1153696

I have tried the "WordPress access details" you provided above, it is not valid, I get this error:
ERROR: The username or password you entered is incorrect.

Please check it.

#1153700

Jas

Ok I edited the password. can you see if that works? Sorry!!!

#1153714

Thanks for the details, I can login your website, and have done below modifications in your website:
1) Edit the view "Pay scale":
enlace oculto

in section "Loop Editor", line 14~15 edit the codes as below:

<p><a href="<em><u>enlace oculto</u></em> id='$current_page']">[wpv-post-featured-image size="medium"]</a></p>
<h4><a href="<em><u>enlace oculto</u></em> id='$current_page']">[wpv-post-title]</a></h4>

2) Edit the content template "Template for Pages 2":
enlace oculto

Change the shortcode to:

[wpv-login-form redirect_url='[wpv-search-term param="redirect_to"]']

Test it in front-end as a visitor:
enlace oculto

click the PDF link "Pay Scale", then login, it works fine. please check if it is what you want. thanks

#1154424

Jas

Ok that is definately much better, but so:

1) is it possible to, upon clicking a PDF for download, then following the promt to log in, to automatically redirect straight to the PDF or straight to downloading it? (meaning to skip the step of going back to the page they were on and re-clicking the PDF, but instead, to go directly

2) Then how do we also change the login in the main navigation so that when a person logs in from any page, they automatically are re-directed back to that page. Currently they are re-directed to the wp-admin, and I definately don't want subscribers to be taken there.

Thanks so much Lou Yang!!!! Appreciate this help!

Los hilos nuevos creados por Luo Yang y vinculados a este se encuentran a continuación:

https://toolset.com/es/forums/topic/change-the-login-in-the-main-navigation-so-that-when-a-person-logs-in-from-any-page/

#1154474

Q1) Yes, it is possible, as you can see, in my answer above:
https://toolset.com/forums/topic/redirect-after-login-3/#post-1153714

I am using shortcode [wpv-post-url id='$current_page'] to setup the link, this shortcode will output current page URL of "housekeeper-resources".

You can change it to "PDF Downloads" post URL, for example replace it with [wpv-post-url].

Q2) This is another problem, I have created a new ticket for it, please check it here:
https://toolset.com/forums/topic/change-the-login-in-the-main-navigation-so-that-when-a-person-logs-in-from-any-page/

#1154504

Jas

Ok, I know i'm sounding really dense, but I just have no experience whatsoever with html at all. Just going by what I can sort of assume when looking at in my ignorance. Yes, I can understand why that would output Housekeeper resources because I can assume that [wpv-post-url id='$current_page'] (and specifically '$current_page') is the Id that obviously must be required. However, are you saying I need to do somehting like this?:

<p>enlace oculto id='pdf-downloads']">[wpv-post-featured-image size="medium"]</p>
<h4>enlace oculto id='pdf-downloads']

But this doesn't work, so I'm not understanding clearly what you are saying .SORRY FOR BEING SUCH A PAIN!!!!!!

#1154534

Jas

also the link for:

"New User? Register here first to login."

Is no longer showing on the login:(

#1154539

I have edit your view
enlace oculto
in section "Loop Editor", setup the link as below:

<p><a href="<em><u>enlace oculto</u></em> field='download-file' output='raw'][/types]">[wpv-post-featured-image size="medium"]</a></p>
<h4><a href="<em><u>enlace oculto</u></em> field='download-file' output='raw'][/types]">[wpv-post-title]</a></h4>

It is using "download-file" field value in the link.

Please test again, check if it is fixed.

#1155983

Jas

Fantastic Lou Yang!!! Just one small tweek left on this.

When people are already logged in, the PDF opens in a new window (Yay!!! this is perfect!)

When guests are logged out, then clicke a PDF and then are prompted to login, the PDF opens directly after logging in, only this time, it opens in that same window (which isn't perfect, it needs to open in a new window)