Skip Navigation

[Résolu] Need PDF to re-direct differently

This support ticket is created Il y a 5 années et 11 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Marqué : 

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

Dernière mise à jour par Nigel Il y a 5 années et 11 mois.

Assisté par: Nigel.

Auteur
Publications
#1165316

Jas

I am trying to:
Hi, I had a support thread with you already on this issue, and it was mostly solved. I was trying to have a logged OUT/guest user to get a prompt to login in order to access a restricted PDF. This was accomplished by adding:

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
<p>lien caché field='download-file' output='raw'][/types]" target="_blank">[wpv-post-featured-image size="medium"]</p>
<h4>lien caché field='download-file' output='raw'][/types]" target="_blank">[wpv-post-title]</h4>
[wpv-post-body view_template="None"]
[/wpv-conditional]

To this View:
lien caché

However, it then only showed a login form for those who are already members, WITHOUT showing the "New user registration" or "forgot password" fields. Which I need it to have at the juncture so that they can first become members, then sign in.

So I tried changing the /login/ portion of:
"lien caché field='download-file' output='raw'][/types]" target="_blank">[wpv-post-featured-image size="medium"]</p>

to/my-account/:

"lien caché field='download-file' output='raw'][/types]" target="_blank">[wpv-post-featured-image size="medium"]</p>

Which DID then show the proper form, but then after logging in, instead of opening the PDF download, it goes to the version of the my-account page that shows when a person is logged in (with the logout link).

#1165552

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

What page are people on when they see this?

I'm not sure how I would expect the login redirects to work when you add the URL of the file itself as the redirect destination rather than a page.

I would imagine a workflow something like

- the user is visiting a post, and that post has a custom field which is a file link
- if the user is logged in they see the file link
- if the user is logged out they see a login link which goes to a custom login page
- on the custom login page there are login options and sign-up options
- these redirect back to the original post, so that page will be reloading, but this time the user is logged in and sees the file link

It looks like you already have a custom login page set up.

What if you change the redirect parameters to the originating post rather than the file download links?

#1167380

Jas

Ok so the page in question is:

lien caché

And if you scroll down to the "What to Pay" section. At the very end of it, you will see a View with the Pay Scale PDF preview. Click on Pay Scale (English version). It correctly opens up to the login window with appropriate options for registering.

Currently if they are already logged in, it opens the file up in a new tab, which is perfect. and
And for those who aren't yet logged in, I guess it's ok if it redirects back to the page they were on. I was hoping that it would go directly to open the PDF in a new tab from login, but if that can't happen, that's ok. Currently it lands them on their account page, which is not ok.

This is what I had changed the View for Payscale to (which still takes them to their account page after logging in, and not the current page:

[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é id='$current_page']">[wpv-post-featured-image size="medium"]</p>
<h4>lien caché id='$current_page']">[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]

#1167653

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I just tested the following on my local site where it worked as expected.

I display the link to the PDF file for logged-out users as a link opening in a new tab to the login page with a redirect to the PDF file itself.

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
<a href="[wpv-bloginfo show='url']/wp-login.php/?redirect_to=[types field='document' output='raw'][/types]" target="_blank">The link</a>
[/wpv-conditional]

That is using the standard login page but I expect it to work with a custom login page, too.

Check the above and see if the same works on your site (editing for the field slug, of course).

#1169461

Jas

Sorry for the ignorance. It worked when I had the standard login in the view, but I can't seem to make it work with the full login/registration/forgot password as I have it below. It opens still to the my account page. (sorry, I obviously don't even know html, just trying to compare and do what I assume you mean) (to me it looks like there are double of the same thing below too?)

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
<p>lien caché field='download-file' output='raw'][/types]" target="_blank">lien caché size="medium"]</p>
<h4>lien caché field='download-file' output='raw'][/types]" target="_blank">[wpv-post-title]</h4>
[wpv-post-body view_template="None"]
[/wpv-conditional]

#1169810

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I wanted to look at how you have your my-account page set up to see if I could spot where the problem lies, but the password you supplied doesn't work.

Can I get updated credentials from you?

#1170269
#1170515

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I can't see how the my account page is made because there are errors on the page (you are using the new Divi front-end editor which we do not yet support, we are hoping to release an update soon that adds support).

I don't want to do anything to damage your site, so I'm taking a copy of your site that I can work on locally where I can try and revert to the classic Divi editor to see how the page is made.

I'll need a little time to set that up, please bear with me.

#1170599

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

OK, it took some digging, but I see how you have this set up and think I have identified the problem.

Specifically, your my account page uses Access to show a template with a custom login form instead, that is inserted with the wpv-login-form shortcode.

https://toolset.com/documentation/user-guides/views-shortcodes/#vf-295292

If you want a custom redirect that shortcode needs a redirect_url attribute setting, so you need to effectively grab the URL parameter you are using and set the redirect_url attribute with it.

You can get the value of the URL parameter using the wpv-search-term shortcode (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term), so you should update your wpv-login-form shortcode like so:

{!{wpv-login-form redirect_url='{!{wpv-search-term param="redirect_to"}!}'}!}

(Shortcodes normally use square brackets but because you are using Divi they are inserted with { } curly braces.)