skokolopoulos
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [New User Approve] Redirect a user until approveddenied users
if(class_exists('pw_new_user_approve')) { $user_id = get_current_user_id(); if(!empty($user_id)) { $status = pw_new_user_approve()->get_user_status( $user_id ); if($status == 'denied') { add_action('template_redirect', 'NUA_redirect_denied_users'); } } } function NUA_redirect_denied_users() { $current_page_id = get_queried_object_id(); $page_id_1 = 457; // You should replace the page ID with the IDs of the page that you do not want unapproved users to access $page_id_2 = 322; // You should replace the page ID with the IDs of the page that you do not want unapproved users to access $page = get_post($page_id); if ($current_page_id == 457) { wp_logout(); //if (($current_page_id == 457) || ($current_page_id == 322){ wp_redirect('https://mydomain/denied-user/'); // you can use here the any url page where you want to redirect the unapproved user exit; } $page = get_post($page_id_2); if ($current_page_id == 322) { wp_logout(); wp_redirect('https://mydomain/denied-user/'); // you can use here the any url page where you want to redirect the unapproved user exit; } }
- This reply was modified 8 months, 3 weeks ago by skokolopoulos.
Forum: Plugins
In reply to: [New User Approve] Redirect a user until approvedThank you very much,
Ι use the code and it works perfectly.
Because I wanted to check two posts, I changed the code a bit as you can see below.
Also, because for the connection of the members I use the registration via google account, it did not cover the case of denied access (they connected to the website even if I set them to deny), so I created a snippet to cover this case as well. Thanks again.if(class_exists('pw_new_user_approve')) { $user_id = get_current_user_id(); if(!empty($user_id)) { $status = pw_new_user_approve()->get_user_status( $user_id ); if($status == 'pending') { add_action('template_redirect', 'NUA_redirect_users'); } } } function NUA_redirect_users() { $current_page_id = get_queried_object_id(); $page_id_1 = 457; // You should replace the page ID with the IDs of the page that you do not want unapproved users to access $page_id_2 = 322; // You should replace the page ID with the IDs of the page that you do not want unapproved users to access $page = get_post($page_id); if ($current_page_id == 457) { wp_logout(); //if (($current_page_id == 457) || ($current_page_id == 322){ wp_redirect('https://mydomain/log-out-user/'); // you can use here the any url page where you want to redirect the unapproved user exit; } $page = get_post($page_id_2); if ($current_page_id == 322) { wp_logout(); wp_redirect('https://mydomain/log-out-user/'); // you can use here the any url page where you want to redirect the unapproved user exit; } }
- This reply was modified 8 months, 3 weeks ago by skokolopoulos.
Viewing 2 replies - 1 through 2 (of 2 total)