um_access_global_settings

The Ultimate Member um access global settings function.

Description

um_access_global_settings(); 

Usage

  1. if ( !function_exists( 'um_access_global_settings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ultimate-member/core/um-actions-access.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = um_access_global_settings(); 
  7.  

Defined (1)

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

/core/um-actions-access.php  
  1. function um_access_global_settings() { 
  2. global $post, $ultimatemember; 
  3.  
  4. $access = um_get_option('accessible'); 
  5.  
  6. if ( $access == 2 && ! is_user_logged_in() ) { 
  7.  
  8. $redirect = um_get_option('access_redirect'); 
  9. if ( !$redirect ) { 
  10. $redirect = um_get_core_page('login'); 
  11.  
  12. $redirects[] = untrailingslashit( um_get_core_page('login') ); 
  13. $redirects[] = untrailingslashit( um_get_option('access_redirect') ); 
  14.  
  15. $exclude_uris = um_get_option('access_exclude_uris'); 
  16.  
  17. if ( $exclude_uris ) { 
  18. $redirects = array_merge( $redirects, $exclude_uris ); 
  19.  
  20. $redirects = array_unique( $redirects ); 
  21.  
  22. $current_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') ); 
  23. $current_url = untrailingslashit( $current_url ); 
  24. $current_url_slash = trailingslashit( $current_url ); 
  25.  
  26. if ( ( isset( $post->ID ) ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) { 
  27. // allow 
  28. }else { 
  29. $ultimatemember->access->redirect_handler = $ultimatemember->access->set_referer( $redirect, "global" ); 
  30.  
  31. // Disallow access in homepage 
  32. if( is_front_page() || is_home() ) { 
  33. $home_page_accessible = um_get_option("home_page_accessible"); 
  34. if( $home_page_accessible == 0 ) { 
  35. $ultimatemember->access->redirect_handler = $ultimatemember->access->set_referer( $redirect, "global" ); 
  36.  
  37. wp_redirect( $ultimatemember->access->redirect_handler ); exit; 
  38.  
  39.  
  40. // Disallow access in category pages 
  41. if( is_category() ) { 
  42. $category_page_accessible = um_get_option("category_page_accessible"); 
  43. if( $category_page_accessible == 0 ) { 
  44. $ultimatemember->access->redirect_handler = $ultimatemember->access->set_referer( $redirect, "global" ); 
  45. wp_redirect( $ultimatemember->access->redirect_handler ); exit; 
  46.  
  47.  
  48. $current_page_type = um_get_current_page_type(); 
  49.  
  50. do_action("um_access_post_type", $current_page_type); 
  51. do_action("um_access_post_type_{$current_page_type}"); 
  52.  
  53.