Home › Forums › Legacy Support › Support queries › Child Themes › How to Redirect instructor page to some other page only for students
Tagged: instructor page, Instructor redirect, redirection
- This topic has 6 replies, 3 voices, and was last updated 8 years, 7 months ago by H.K. Latiyan.
Viewing 7 posts - 1 through 7 (of 7 total)
-
AuthorPosts
-
May 17, 2016 at 7:22 am #48481devpatelSpectatorHi, 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/May 18, 2016 at 8:07 am #48713devpatelSpectatorLooking Forward for your ReplyMay 18, 2016 at 10:20 am #48741Anshuman SahuKeymasterPlease 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 .May 18, 2016 at 12:00 pm #48766devpatelSpectatorNice 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.May 19, 2016 at 11:03 am #49014Anshuman SahuKeymasterWell 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 .
May 20, 2016 at 11:21 am #49319devpatelSpectatorAwesome :) 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.May 21, 2016 at 8:07 am #49468H.K. LatiyanParticipantPlease 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. -
AuthorPosts
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.