pmpro_login_redirect

The Paid Memberships Pro pmpro login redirect function.

Description

pmpro_login_redirect( $redirect_to, $request, $user ); 

Parameters (3)

0. $redirect_to
The redirect to.
1. $request
The request.
2. $user
The user.

Usage

  1. if ( !function_exists( 'pmpro_login_redirect' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/login.php'; 
  3.  
  4. // The redirect to. 
  5. $redirect_to = null; 
  6.  
  7. // The request. 
  8. $request = null; 
  9.  
  10. // The user. 
  11. $user = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_login_redirect($redirect_to, $request, $user); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/login.php  
  1. function pmpro_login_redirect($redirect_to, $request, $user) 
  2. global $wpdb; 
  3.  
  4. //is a user logging in? 
  5. if(!empty($user->ID)) 
  6. //logging in, let's figure out where to send them 
  7. if(pmpro_isAdmin($user->ID)) 
  8. //admins go to dashboard 
  9. $redirect_to = get_bloginfo("url") . "/wp-admin/";  
  10. elseif(strpos($redirect_to, "checkout") !== false) 
  11. //if the redirect url includes the word checkout, leave it alone 
  12. elseif($wpdb->get_var("SELECT membership_id FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . $user->ID . "' LIMIT 1")) 
  13. //if logged in and a member, send to wherever they were going  
  14. else 
  15. //not a member, send tosubscriptionpage 
  16. $redirect_to = pmpro_url("levels"); 
  17. else 
  18. //not logging in (login form) so return what was given  
  19.  
  20. return apply_filters("pmpro_login_redirect_url", $redirect_to, $request, $user);