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>lien caché">[wpv-post-featured-image size="medium"]</p>
<h4>lien caché">[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]
Hello,
How do you setup the login form in the URL "lien caché" ?
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>lien caché</u></em>">[wpv-post-featured-image size="medium"]</a></p>
To:
<p><a href="<em><u>lien caché</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.
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).
Yes, it should be able to work, you can test it and feedback if there is any problem.
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 "lien caché;
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.
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.
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.
Ok I edited the password. can you see if that works? Sorry!!!
Thanks for the details, I can login your website, and have done below modifications in your website:
1) Edit the view "Pay scale":
lien caché
in section "Loop Editor", line 14~15 edit the codes as below:
<p><a href="<em><u>lien caché</u></em> id='$current_page']">[wpv-post-featured-image size="medium"]</a></p>
<h4><a href="<em><u>lien caché</u></em> id='$current_page']">[wpv-post-title]</a></h4>
2) Edit the content template "Template for Pages 2":
lien caché
Change the shortcode to:
[wpv-login-form redirect_url='[wpv-search-term param="redirect_to"]']
Test it in front-end as a visitor:
lien caché
click the PDF link "Pay Scale", then login, it works fine. please check if it is what you want. thanks
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!
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/
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>lien caché id='pdf-downloads']">[wpv-post-featured-image size="medium"]</p>
<h4>lien caché id='pdf-downloads']
But this doesn't work, so I'm not understanding clearly what you are saying .SORRY FOR BEING SUCH A PAIN!!!!!!
also the link for:
"New User? Register here first to login."
Is no longer showing on the login:(
I have edit your view
lien caché
in section "Loop Editor", setup the link as below:
<p><a href="<em><u>lien caché</u></em> field='download-file' output='raw'][/types]">[wpv-post-featured-image size="medium"]</a></p>
<h4><a href="<em><u>lien caché</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.
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)