How to Redirect instructor page to some other page only for students

Home Forums Legacy Support Support queries Child Themes How to Redirect instructor page to some other page only for students

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #48481
    devpatel
    Spectator
    Hi, I want to redirect instructor page to some custom page like Original page:- http://www.demo.com/members/instructor1/ Redirection Page:- http://www.demo.com/test_page/ for this I tried to do 301 redirect from .htaccess it works fine but Now the instructor in unable to see its own pages like dashboard and courses, I wanted to do this only for students and non logged in users, for instructor and admin all the pages will be same, Means for Instructor and admin Original page:- http://www.demo.com/members/instructor1/ Redirection Page:-<span style="line-height: 1.5;">http://www.demo.com/members/instructor1/ </span>For Non Logged in and students :- Original page:- http://www.demo.com/members/instructor1/ Redirection Page:- http://www.demo.com/test_page/
    #48713
    devpatel
    Spectator
    Looking Forward for your Reply
    #48741
    Anshuman Sahu
    Keymaster
    Please try adding the given code in your wplms-customizer.php file in wplms customizer plugin : add_action('wplms_before_member_profile','restrict_student_From_inst_profile'); function restrict_student_From_inst_profile(){   if(is_user_logged_in() && user_can(bp_displayed_user_id(),'edit_posts') && !bp_is_my_profile() && !current_user_can('edit_posts')){      echo  '<script>       window.location = "http://www.yoururl.com";      </script>';   }   } Change the " http://www.yoururl.com " to your page .
    #48766
    devpatel
    Spectator
    Nice Thanks it works fine for one instructor But what about Instructor 2 and instructor 3 means for more than one instructor, I want to refer you to a website :- http://neostencil.com/ for checking the functionality what I want to implement. Please check the functionality of there instructor page on home page.
    #49014
    Anshuman Sahu
    Keymaster
    Well i have provided the code to restrict the students from watching instructor profiles .But instructors and admins  can see each other profiles . If you want this redirect for instructors also then please remove the above code and add this code :

    add_action('wplms_before_member_profile','restrict_student_From_inst_profile');

    function restrict_student_From_inst_profile(){

      if((is_user_logged_in() && user_can(bp_displayed_user_id(),'edit_posts') && !bp_is_my_profile() && !current_user_can('manage_options')) || !is_user_logged_in()){

         echo  '<script>

          window.location = "http://www.yoururl.com";

         </script>';

      }

     } With the above code even onstrcutors cannot see other instrcutor's profiles but admins can . However a instructor can see her own profile .

     
    #49319
    devpatel
    Spectator
    Awesome :) Alex but this is not what I am talking about, I am talking about :- I have multiple instructor and multiple dedicated page for them, Something like Instructor 1 :-   Original page:- http://www.demo.com/members/instructor1/ Redirection Page:- http://www.demo.com/test_page/ Instructor 2:- Original page:- http://www.demo.com/members/instructor2/ Redirection Page:- http://www.demo.com/test_page2/ Instructor 3:- Original page:- http://www.demo.com/members/instructor3/ Redirection Page:- http://www.demo.com/test_page3/ Instructor 4:- Original page:- http://www.demo.com/members/instructor4/ Redirection Page:- http://www.demo.com/test_page4/ Cases are same as we are talking since last few days that is redirection will be only for student and non logged in user. I have given you a reference website neostencil.com, build on wplms and having the same functionality what I am talking about, If you go to the site and click on any instructor it will redirect you to their dedicated page Example :- 1.  http://neostencil.com/members/pavankumarias/  goes to http://neostencil.com/pavankumarias/ 2. http://neostencil.com/members/praveenkishore/ goes to http://neostencil.com/niceias/ Please help me to get this.
    #49468
    H.K. Latiyan
    Participant
    Please remove the above code and use this code instead:   add_action('wplms_before_member_profile','restrict_student_From_inst_profile'); function restrict_student_From_inst_profile(){   if((is_user_logged_in() && user_can(bp_displayed_user_id(),'edit_posts') && !bp_is_my_profile() && !current_user_can('manage_options')) || !is_user_logged_in()){      echo  '<script>       window.location = "'.home_url().'/'.bp_core_get_username(bp_displayed_user_id()).'";      </script>';   }  }   NOTE: Now you have to create the pages as the instructor username. For example yoursite.com/members/instructor will be redirected to yoursite.com/instructor    so the instructor page must exists. 
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘How to Redirect instructor page to some other page only for students’ is closed to new replies.