Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Button to "my course" page
- This topic has 11 replies, 3 voices, and was last updated 4 years, 7 months ago by logan.
Viewing 12 posts - 1 through 12 (of 12 total)
-
AuthorPosts
-
August 15, 2019 at 8:44 pm #222474dav80SpectatorHello, Is it a way to create a button allow to redirect to the My Course page ? ThanksAugust 16, 2019 at 8:27 am #222545DianaParticipant@dav80 Where do you want to add this button. Please share a screenshotAugust 16, 2019 at 9:46 am #222565dav80SpectatorHello, We need to create a button on the home page. We force login to access to the home page. So i need to retrieve the username of the current user to insert this variable into the url button as below : https://myurl/all-courses/USER/course/ But i don't know how to retrive dynamically the USER variable. Pending readAugust 17, 2019 at 1:24 pm #222738loganMemberHello, yes that is possible, i will try to create a shortcode then that will fetch the current user detail but I need some answers:
- do you want to add the button by elementor or any page builder??
- the styling of page builder won't apply on this button.
- tell me the exact styling of the button and place so that i can write specific codes.
August 17, 2019 at 4:14 pm #222757dav80SpectatorHello, 1.Yes i can use elementor or code directly. 2.No problem 3.Green button, rounded. I will personnalised it. ThanksAugust 19, 2019 at 8:55 am #222836loganMemberHello, refer this: http://somup.com/cqjqjaeZcg Please paste this snippets in your wp-admin >> plugins >> editor >> wplms-customizer plugin >> wplms-customizer.php Or in Please add this code in your wplms-customizer.php file in wplms customizer plugin by using your FTP/SFTP/cpanel: add_shortcode('button_to_my_course',function (){ ?> <style> a.logan_button_to_my_course { background: green; padding: 10px 25px; border-radius: 10px; color: white; </style> <?php $current_user = wp_get_current_user(); $username = $current_user->user_login; $url= get_home_url().'/members/'.$username.'/course'; return "<a href='$url' class='logan_button_to_my_course'> My Courses </a>"; }); use shortcode [button_to_my_course]August 19, 2019 at 9:46 am #222845dav80SpectatorHello, Thank you for this code. The code works but i have a problem with usernamue wich contains space. When user name contain space à %20 is added in the url instead of the space. But we need a - instead of %20 to allow good redirection. With a %20 it generated a 404 error. In the url we need to replace space by - Is it a way to make this change ? ThanksAugust 19, 2019 at 10:17 am #222852loganMembertry this: Please add this code in your wplms-customizer.php file in wplms customizer plugin by using your FTP/SFTP/cpanel: add_shortcode('button_to_my_course',function (){ ?> <style> a.logan_button_to_my_course { background: green; padding: 10px 25px; border-radius: 10px; color: white; </style> <?php $current_user = wp_get_current_user(); $username = urlencode($current_user->user_login); $url= get_home_url().'/members/'.$username.'/course'; return "<a href='$url' class='logan_button_to_my_course'> My Courses </a>"; });August 19, 2019 at 10:24 am #222854dav80SpectatorThis change replace the %20 by a + instead of a - Any idea ?August 20, 2019 at 7:18 am #222987loganMemberHello, try this code. add_shortcode('button_to_my_course',function (){ ?> <style> a.logan_button_to_my_course { background: green; padding: 10px 25px; border-radius: 10px; color: white; </style> <?php $url= bp_core_get_user_domain(get_current_user_id()).'course'; return "<a href='$url' class='logan_button_to_my_course'> My course button </a>"; });August 20, 2019 at 7:29 am #222990dav80SpectatorHello, It's works like a charm ! Thank you.August 20, 2019 at 8:10 am #222996loganMemberFriend,
for all my efforts, i hope you wouldn't mind writing a detailed review about your experience with WPLMS and our customer support.
Here: https://themeforest.net/item/wplms-learning-management-system/reviews/6780226
If I can be of assistance, please do not hesitate to contact me again.
Closing this topic. best regards friend.
-
AuthorPosts
Viewing 12 posts - 1 through 12 (of 12 total)
- The topic ‘Button to "my course" page’ is closed to new replies.