Skip Navigation

[Resuelto] add_action( 'wpv_wp_login_success ??

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

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Etiquetado: 

Este tema contiene 14 respuestas, tiene 4 mensajes.

Última actualización por Beda hace 6 años, 3 meses.

Asistido por: Beda.

Autor
Mensajes
#1076601

Hi, is there any login_sucess ?

I wanted to achieve this, upon successful login to display bootstrap notification success bar with close button,

i only see this action filter in wpv-shortcode.php .

add_action( 'wpv_wp_login_failed', 'wpv_login_form_fail_redirect', 30, 2 );

i know i have the option to add an abs url but thats not what i want . thanks

looking at the code i would like to suggest to add an option for " custom message /modal prompt " for both login fail and success.

#1077227

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi there

I looked to see if it were possible with some other filter or action but couldn't find anything that would help.

So I need to make a feature request out of this, which I am now doing.

It will be evaluated by the developers.

We do intend to add a public feature request system where uses will be able to add and vote on features, but it is not ready yet.

#1077245

Hi Nigel

Since its a standard wp-login form is there any other filter that can be used ?

i am fine with the redirect for now but just that how do i prevent direct linking to the url ?

example: site.com/login_ok as my login success redirect, i dont want to have direct url enter for this.

i found this code but its not working : https://stackoverflow.com/questions/48588816/prevent-block-direct-access-to-a-thank-you-page

thanks!

#1077246

Hello, Nigel assigned me this as it's a feature request.

It seems you need a way to display a success message on a login page (after successful login) - and this either as a GUI option or with Custom Code applied to a Toolset hook.

I think what you need is possible with some conditional, I will check this and reply you later.

#1077347

hi. yes Conditional codes will be good too.

#1078358

1. I wanted to achieve this, upon successful login to display bootstrap notification success bar with close button

Why do you not just use a Custom Success message or redirect upon successful login?

This can all be set in the very login ShortCode.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-login-form

2. You could:
- insert the Login Form to a page
- pass either a new URL (new page, with success message) to the redirect_url attribute of the ShortCode
- or, pass the same page, with a Search parameter, to the same redirect_url attribute

General Example:

[wpv-login-form redirect_url="[wpv-bloginfo show="url"]/?success=yes"]

Now, when the user logs in, and the login is correct, it will lead to that exact URL.

Either you put a message on that page, or you display one conditionally anywhere you lead to:

[wpv-conditional if="( '[wpv-search-term param="success"]' eq 'yes' )"]
  yes!
[/wpv-conditional]

I don't think this needs a new feature, unless I do not understand the things requested.

Please let me know what you think

#1078599

Hi ,

Why do you not just use a Custom Success message or redirect upon successful login
1 .where is the Custom Success message in the shortcode ?

create a new page, with success message ,
2. thats what i have now here: enlace oculto .
this doesnt make sense to me as any public can enter with direct url . is there anything can be done to prevent this ?
perhaps snippets that bolock direct acess to urs except with a url refer '/login' ?

page, with a Search parameter,
3. how do do this ?

ive added both code ,

once login it direct to ..../?success=yes ....its a 404 page.

#1079676

anyone ?

#1079840

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Nigel is on Vacation. This is Minesh here and I will take care of this ticket. Hope this is OK.

To restrict your page for non logged in users.

Please try to add following code to your current theme's functions.php file.

function func_restrict_access_to_successpage() {

$postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
$user = wp_get_current_user();

   if( $postID == 9999 and $user->ID=='') {
         wp_redirect( home_url());
         exit();
   }


}
add_action( 'init', 'func_restrict_access_to_successpage' );

Where:
- Replace 9999 with your success page ID

#1080196

I am not sure why we should solve this with custom code, I apologies, if I do miss something, Please let me know.

Maybe my previous instructions where to broad, so I reformulated it.

The Goal:
Display a success message after successful login.

The Best Solution with Toolset for this is (can be):
1. insert the Login Form ShortCode to a page (any-page)
2. pass the same page's full URL (site.com/any-page), with a Search parameter added to the URL, to the `redirect_url` attribute of the Login Form ShortCode (this is used when the login is successful)
Example:

[wpv-login-form redirect_url="[wpv-bloginfo show="url"]/any-page/?success=yes"]

Of course, you need to replace "any-page" with the real slug of your page where the login form is.
==> Now, when the visitor logs in, and the login is correct, it will lead to that exact URL (site.com/any-page/?success=yes)
3. On the same page where you display this login form, display your success message - conditionally, using Conditional HTML ShortCodes available in Toolset:

[wpv-conditional if="( '[wpv-search-term param="success"]' eq 'yes' )"]
  yes! PUT THE MESSAGE HERE
[/wpv-conditional]

We are listening to the Search parameter - which is the ?success=yes part.
If that is yes, then we display the message, otherwise not.

The filter requested for this is not required, it could not even solve the goal.

The code shared by Minesh is restricting access to a page, in particular, I am not sure as well why that should be done with Custom Code, as to hide or not allow access to pages we do use Toolset Access, however, that is not even the topic here.

Please, let me know if anything is unclear.

The steps shown above will do exactly what you require.

It will show a Login Form, and upon successful login a success message.

Usually we do that on a specific page, hence, we do not display the "success message" directly on the login page but redirect somewhere else.
This because otherwise when the user is logged in, he will always see the success message.

It depends a lot here on what the content of your messages are.

Please let me know if this works for you - otherwise I can set up a dummy test for you on the site.
But the steps above should lead to the exact desired outcome.

#1080197

Changing status

#1080217

Thank You both for taking time to reply .

The solution works perfectly , amazed what the search parameters can be used for ..i like beda solutin as i no need to create another extra page for sucesss message .

i was wondering if i can put/place all this mesaages in the homepage instead of login page ?

#1080219

You can add this wherever you want.

The logic is that you add the Message within it's conditional to the page where you finally want to display this.

The login form always should redirect to that page on success, and always should append the URL parameter as instructed.

Then, the message will show.

However Home is only a Page if you set a static home page.
Other wise it's an archive and needs to be edited in WordPress Archives or Layouts for it.

The principle is the same. URL parameters generally don't care where they are added to, and things listening to it will just listen to what comes after ?param=

Hence, you can add it as well to a home page.

I do not recommend it because it would be strange to have a success message on the home page - I would expect this more on a specific login page, but that always depends on the setup

#1080243

Thanks for the details,

my setup is such that the message is alert box with auto close. so it will disappear leaving home page.
you can see here:

enlace oculto
enlace oculto

Now how i hide this page from direct access ? if direct access lead to 404 etc .can use this string in the access ?

#1086519

How would you do that?
If you block your home page from first access (which is not possible anyway in Toolset, it requires custom code to restrict access just ONCE), no one is able to access it, and the URL parameter does not make a new page, it's still the same page - with a URL parameter.

If you want to hide the message itself, just wrap it in a condition more, that checks if the user is logged in (makes sure the success message is display only if the user is login AND the success URL parameter is set).

If you want to have the whole URL inaccessible then you need Custom Code, there is no way in Toolset to hide/show on first load or referrer urls conditions.

What you can follow to create custom code is this:
https://stackoverflow.com/questions/23854192/allow-access-only-when-redirected-from-a-particular-page

It shows how to allow access only if a referrer is xy.
That can help to hide a Success Page, with Success Message, and show it only if the referrer URL is a particular URL.

Again, that URL is not existent, unless someone who knows the URL copy pastes it - which is likely to not do any harm.