/**
  * Handles logout redirection
  *
  * Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
  *
  * @see Theme_My_Login::the_request()
  * @since 6.0
  * @access public
  *
  * @param string $redirect_to Default redirect
  * @param string $request Requested redirect
  * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
  * @return string New redirect
  */
 public function logout_redirect($redirect_to, $request, $user)
 {
     // Determine the correct referer
     if (!($http_referer = wp_get_original_referer())) {
         $http_referer = wp_get_referer();
     }
     // Remove some arguments that may be present and shouldn't be
     $http_referer = remove_query_arg(array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce'), $http_referer);
     // Make sure $user object exists and is a WP_User instance
     if (!is_wp_error($user) && is_a($user, 'WP_User')) {
         if (is_multisite() && empty($user->roles)) {
             $user->roles = array('subscriber');
         }
         $user_role = reset($user->roles);
         $redirection = $this->get_option($user_role, array());
         if ('referer' == $redirection['logout_type']) {
             // Send 'em back to the referer
             $redirect_to = $http_referer;
         } elseif ('custom' == $redirection['logout_type']) {
             // Send 'em to the specified URL
             $redirect_to = $redirection['logout_url'];
             // Allow a few user specific variables
             $redirect_to = Theme_My_Login_Common::replace_vars($redirect_to, $user->ID, array('%user_id%' => $user->ID));
         }
     }
     // Make sure $redirect_to isn't empty or pointing to an admin URL (causing an endless loop)
     if (empty($redirect_to) || false !== strpos($redirect_to, 'wp-admin')) {
         $redirect_to = add_query_arg('loggedout', 'true', wp_login_url());
     }
     return $redirect_to;
 }
Ejemplo n.º 2
0
 /**
  * Gets the user links for the current user's role
  *
  * Callback for "tml_user_links" hook in method Theme_My_Login_Template::display()
  *
  * @see Theme_My_Login_Template::display()
  * @since 6.0
  * @access public
  *
  * @param array $links Default user links
  * @return array New user links
  */
 public function get_user_links($links = array())
 {
     if (!is_user_logged_in()) {
         return $links;
     }
     $current_user = wp_get_current_user();
     if (is_multisite() && empty($current_user->roles)) {
         $current_user->roles = array('subscriber');
     }
     foreach ((array) $current_user->roles as $role) {
         if ($links = $this->get_option($role)) {
         }
         break;
     }
     // Define and allow filtering of replacement variables
     $replacements = apply_filters('tml_custom_user_links_variables', array('%user_id%' => $current_user->ID, '%username%' => $current_user->user_nicename));
     // Replace variables in link
     foreach ((array) $links as $key => $link) {
         $links[$key]['url'] = Theme_My_Login_Common::replace_vars($link['url'], $current_user->ID, $replacements);
     }
     return $links;
 }
 /**
  * Changes the user denial e-mail message
  *
  * Callback for "user_denial_notification_message" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
  *
  * @see Theme_My_Login_User_Moderation_Admin::deny_user()
  * @since 6.1
  * @access public
  *
  * @param string $message The default message
  * @param int $user_id The user's ID
  * @return string The filtered message
  */
 public function user_denial_notification_message_filter($message, $user_id)
 {
     $_message = $this->get_option(array('user_denial', 'message'));
     return empty($_message) ? $message : Theme_My_Login_Common::replace_vars($_message, $user_id);
 }