global access setting not work properly
-
Hello
Is this bug or?
[situation]
1. write a post with category
2. did not touch category setting
3. change post’s access settings to logged in user only with redirect url[um setup]
global access setting => Everyone
category access setting => not configured = empty[um-actions-access.php => um_access_post_settings]
um_get_option('accessible) = empty = false // why not 0?, (0: everyone, 2: logged in user only) $accessible => 2 foreach( $categories as $cat ){ $opt = get_option("category_{$cat->term_id}"); if ( isset( $opt['_um_accessible'] ) ) { // this is OK switch( $opt['_um_accessible'] ) { // this return empty value so failed to set $ultimatemember->access->allow_access value case 0: // Open to everyone if( $ultimatemember->access->allow_access == false ) { // empty value cause problem here. below code after category check could not run return; } } } if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) { } if ( !isset( $accessible ) ) return; switch( $accessible ) { } }
switch($accessible) { case 2: // don't know why is_user_logged_in() return true even if anonymouse user ;(, anyway if is_user_logged_in() return wrong value then this code did not work properly }
if( um_is_core_page('user') && ! is_user_logged_in() ){ // maybe should um_is_core_page('user') == false && ! is_user_logged_in() right? $ultimatemember->access->allow_access = false; $ultimatemember->access->redirect_handler = esc_url( $access_redirect ); wp_redirect( $ultimatemember->access->redirect_handler ); exit; }
[bug]
1. um_get_option(‘accessible) should not return empty
2. $opt[‘_um_accessible’] should not empty or should have global access value
3. is_user_logged_in() return true when I visit after cleared all cache and cookies (+logout at all)
4. um_is_core_page(‘user’) return false on custom post or page. but check true value to redirect… so didn’t work properly[fix]
for #1,2 add below code before check isset($opt[‘_um_accessible’])if( empty($opt['_um_accessible']) ) { $opt['_um_accessible'] = empty(um_get_option('accessible')) ? 0 : um_get_option('accessible'); }
for #3
use wp_get_current_user() instead is_user_logged_in(). wp_get_current_user()->ID return 0 with logged out userfor #4 change if compare
if( um_is_core_page(‘user’) && ! is_user_logged_in() ){
==>> if( ! um_is_core_page(‘user’) && wp_get_current_user()->ID == 0 ){Thank you for making nice plugin!
Hope this help to fix bug
- The topic ‘global access setting not work properly’ is closed to new replies.