UM_Access

The Ultimate Member UM Access class.

Defined (1)

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

/core/um-access.php  
  1. class UM_Access { 
  2.  
  3. function __construct() { 
  4.  
  5. $this->redirect_handler = false; 
  6. $this->allow_access = false; 
  7.  
  8. add_action('template_redirect', array(&$this, 'template_redirect'), 1000 ); 
  9.  
  10.  
  11.  
  12. /** 
  13. * Set custom access actions and redirection 
  14. */ 
  15. function template_redirect() { 
  16. global $post, $ultimatemember; 
  17.  
  18. do_action('um_access_global_settings'); 
  19.  
  20. do_action('um_access_user_custom_homepage'); 
  21.  
  22. do_action('um_access_frontpage_per_role'); 
  23.  
  24. do_action('um_access_homepage_per_role'); 
  25.  
  26. do_action('um_access_category_settings'); 
  27.  
  28. do_action('um_access_post_settings'); 
  29.  
  30. if ( $this->redirect_handler && $this->allow_access == false && ! um_is_core_page('login') ) { 
  31.  
  32. // login page add protected page automatically 
  33.  
  34. if ( strstr( $this->redirect_handler, um_get_core_page('login') ) ) { 
  35. $curr = $ultimatemember->permalinks->get_current_url(); 
  36. $this->redirect_handler = esc_url( add_query_arg('redirect_to', urlencode_deep($curr), $this->redirect_handler) ); 
  37.  
  38. wp_redirect( $this->redirect_handler ); 
  39.  
  40.  
  41.  
  42.  
  43. /** 
  44. * Get custom access settings meta 
  45. * @param integer $post_id  
  46. * @return array 
  47. */ 
  48. function get_meta( $post_id ) { 
  49. global $post; 
  50. $meta = get_post_custom( $post_id ); 
  51. if ( isset( $meta ) && is_array( $meta ) ) { 
  52. foreach ($meta as $k => $v) { 
  53. if ( strstr($k, '_um_') ) { 
  54. $k = str_replace('_um_', '', $k); 
  55. $array[$k] = $v[0]; 
  56. if ( isset( $array ) ) 
  57. return (array)$array; 
  58. else 
  59. return array(''); 
  60.  
  61. /** 
  62. * Sets a custom access referer in a redirect URL 
  63. * @param string $url  
  64. * @param string $referer  
  65. */ 
  66. function set_referer( $url, $referer ) { 
  67.  
  68. $enable_referer = apply_filters("um_access_enable_referer", false ); 
  69. if( ! $enable_referer ) return $url; 
  70.  
  71. $url = add_query_arg('um_ref', $referer, $url); 
  72. return $url; 
  73.