Change the text on the "Take Course" button based on membership

Home Forums Legacy Support Support queries How-to & Troubleshooting Change the text on the "Take Course" button based on membership

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #50805
    mfarmer
    Spectator
    I 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.
    #50968
    Anshuman Sahu
    Keymaster
    Please 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;     }   }
    #50989
    mfarmer
    Spectator
    I'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?
    #50992
    mfarmer
    Spectator
    I 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?
    #51027
    H.K. Latiyan
    Participant
    Yes you can remove it as its not being used in the code.
    #51429
    mfarmer
    Spectator
    Thanks
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.