Mm Ajax Login

This plugin allows you to create special links that check whether a user is logged in and then follow the link if they are or show an ajax-powered login form in a simple lightbox if they are not. Once the user fills out the login form with valid credentials they will be logged in and redirected to the page the link points to.

Scenario

Let’s say you’ve got a page on your site that only logged in users are able to access. It could be a private page or ideally it is a page that is set up to show a standard login form to users who are not logged in. With this plugin you could add the class ‘ajax-login-trigger’ to all the links that point to that page, then when a user clicks one of these links an ajax request is sent to the server to check whether the user is already logged in, and if they are the user is redirected to the page without ever noticing that the login check was done, or if they aren’t logged in they’ll see a login form appear in a simple lightbox. When the user fills out the form, a second ajax request is sent to the server to attempt to log them in, and if successful the user is redirected to the page.

Customize It!

This plugin includes lots of hooks and filters that allow for all sorts of customizations and unique use cases. Here’s a quick list:

操作:

Filters:

Many things are possible with these hooks. The hooks mm_ajax_login_before_form_inside and mm_ajax_login_after_form_inside allow you to add any custom input elements to the form. When the login form is submitted all of the values from the input elements included in the form will get passed to the PHP function that processes the ajax request, which will then pass the data to the mm_ajax_login_custom_login_action filter. You can intercept the incoming data using this filter and proceed with any custom action you want, like registering new users and logging them in during the same action.

Filter Examples

Use a custom selector for the trigger link:

Use a custom status message:

This plugin is on Github and pull requests are always welcome.

0

评论0

 
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
显示验证码
没有账号?注册  忘记密码?

社交账号快速登录