shop2world
asked 1 month ago

Hello.
1year ago I did ask this issue.

HTTP ERROR 404 for private posting only (There is no problem with the person who wrote and answered.)


 
“At the moment, the plugin does not support redirecting into another page when other users open the private question as you mentioned here.  However, we have sent and notified to our technical team about this issue, we will check and add an option to the next version.”
 

Is it possible now? Or please let me know what to do.
thanks!


1 Answers
DominicStaff
answered 1 month ago

Hi,
About this issue, you can add the following code to the functions.php file to redirect the user to the page that you want.

function redirect_to_login() {
    global $wp_query,$wpdb;
    if (is_404()) {
      $private = $wpdb->get_row($wp_query->request);
      if( 'private' == $private->post_status  ) {
        wp_safe_redirect(home_url('your-slug-page'));
        die;
      }
    }
  }
  add_action('template_redirect', 'redirect_to_login');
Powered by DW Question & Answer Pro