Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Change the text on the "Take Course" button based on membership
Tagged: membership, Take Course Button
- This topic has 5 replies, 3 voices, and was last updated 8 years, 6 months ago by mfarmer.
Viewing 6 posts - 1 through 6 (of 6 total)
-
AuthorPosts
-
May 29, 2016 at 2:08 pm #50805mfarmerSpectatorI am trying to change the text on the "Take Course" button based on membership/log-in status using the built in filter hook for WPLMS. I need to provide a different message for different member types and log-in statuses. I know that the hook to use is 'wplms_take_this_course_button_label', but I don't know how to use hooks very well. Based on THIS POST by Paid Memberships Pro, this is what I came up with: if(pmpro_hasMembershipLevel('1')) { remove_filter( 'wplms_take_this_course_button_label',('TAKE THIS COURSE','vibe'),$course_id); apply_filters( 'wplms_take_this_course_button_label',('LABEL FOR LEVEL 1','vibe'),$course_id); } if(pmpro_hasMembershipLevel('2')) { remove_filter( 'wplms_take_this_course_button_label',('TAKE THIS COURSE','vibe'),$course_id); apply_filters( 'wplms_take_this_course_button_label',('LABEL FOR LEVEL 2','vibe'),$course_id); } if(pmpro_hasMembershipLevel('3')) { remove_filter( 'wplms_take_this_course_button_label',('TAKE THIS COURSE','vibe'),$course_id); apply_filters( 'wplms_take_this_course_button_label',('LABEL FOR LEVEL 3','vibe'),$course_id); } else { remove_filter( 'wplms_take_this_course_button_label',('TAKE THIS COURSE','vibe'),$course_id); apply_filters( 'wplms_take_this_course_button_label',('MY DEFAULT NON-MEMBER LABEL','vibe'),$course_id); } I know there is a way to do this using the hook the correct way. I have a child theme, with its own functions.php file too... Please help.May 30, 2016 at 3:16 pm #50968Anshuman SahuKeymasterPlease try adding the given code in your wplms-customizer.php file in wplms customizer plugin : add_filter('wplms_take_this_course_button_label','my_custom_labels'); function my_custom_labels($html,$course_id){ if(pmpro_hasMembershipLevel('1')) { $html='You lable for 1 '; } if(pmpro_hasMembershipLevel('2')) { $html='You lable for 2 '; } if(pmpro_hasMembershipLevel('3')) { $html='You lable for 3 '; }else{ return $html; } }May 30, 2016 at 6:46 pm #50989mfarmerSpectatorI'm getting this message when I added the code above in the specified file: Warning: Missing argument 2 for my_custom_labels() in /home/modmarketing/public_html/wp-content/plugins/wplms-customizer/wplms-customizer.php on line 64 I don't know what this means and How do I make this go away?May 30, 2016 at 7:59 pm #50992mfarmerSpectatorI just removed the $course_id parameter in the function so that function my_custom_labels($html,$course_id) BECOMES function my_custom_labels($html) It seems to have worked. Tell me, is this change OK?May 31, 2016 at 6:06 am #51027H.K. LatiyanParticipantYes you can remove it as its not being used in the code.June 2, 2016 at 8:58 am #51429mfarmerSpectatorThanks
-
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
- The topic ‘Change the text on the "Take Course" button based on membership’ is closed to new replies.