Where is the_course_button defined?

Home Forums Legacy Support Support queries How-to & Troubleshooting Where is the_course_button defined?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1571
    DrSchmenge
    Spectator
    I see the_course_button in single-course.php but I can't find where the related function is. Which template file is it in?
    #1840
    Anshuman Sahu
    Keymaster
    It is defined in the wp-content/pluigns/vibe-course-module/includes/ bp-course-functions.php file   in  vibe course module plugin.
    #2225
    DrSchmenge
    Spectator
    Thanks.
    1. I can override that by creating a copy of it in the child theme?
    2. Is the location the same in 1.9.9?
    #2468
    Anshuman Sahu
    Keymaster
    No you cannot the the_course_button function . The whole student access to the course logic is dependent on this button . Can you please explain in detail what exactly you want to do in the the_course_button function ?
    #2497
    DrSchmenge
    Spectator
    I'm trying to customize the link for PMPro found in this function:
    function wplms_check_pmpro_button($link){ $course_id = get_the_ID(); if ( in_array( 'paid-memberships-pro/paid-memberships-pro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )) { $membership_ids=vibe_sanitize(get_post_meta($course_id,'vibe_pmpro_membership',false));   if(isset($membership_ids) && is_array($membership_ids) && count($membership_ids)){ $pmpro_levels_page_id = get_option('pmpro_levels_page_id'); $link = get_permalink($pmpro_levels_page_id); } } return $link; }
    I see where <span style="line-height: 1.5;">$link = get_permalink($pmpro_levels_page_id); </span><span style="line-height: 1.5;">and I want to add the author </span><span style="line-height: 1.5;">name to it.</span> I know I have to override the filter but I haven't figured out how to do that with the child theme.
    #2517
    DrSchmenge
    Spectator
      What I need to do is add the course authorname at the end of the pmpro levels link. Don't bother trying to stop me - it has to be done for my site. If you aren't able to help me, I'll be hiring someone else to hack it - unless you are willing to do it for a small bounty.
    #2518
    DrSchmenge
    Spectator
    Where exactly is the Take This Course PMPro link generated? I just deleted the whole 'PMPro Connect' code from the parent themes /includes/func.php and the Take This Course link is fine. No wonder nothing I'm doing is working.
    #2743
    Anshuman Sahu
    Keymaster
    Here you go : Try adding this code in your wplms-customizer.php file in wplms-customizer plugin  :
    add_filter('wplms_course_credits_array','customwplms_course_credits_array',10,2);
    function customwplms_course_credits_array($credits,$id){
        $flag = 0;
        $new_credits = array();
        $author_id = get_post_field('post_author',$id);
        $author = get_user_by('id',$author_id);
       if ( in_array( 'paid-memberships-pro/paid-memberships-pro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
                $membership_ids = vibe_sanitize(get_post_meta($id,'vibe_pmpro_membership',false));
                $match = array();
                if(isset($membership_ids) && is_Array($membership_ids) && count($membership_ids) && function_exists('pmpro_getAllLevels')){
                 $link=get_option('pmpro_levels_page_id');
                 $link=get_permalink($link);
                 foreach($membership_ids as $membership_id){
                    $match[]=$link.'#'.$membership_id;
                 }
                  
                 foreach($credits as $key => $value){
                    if(in_array($key,$match)){
                        $flag=1;
                        $new_credits[$key] = $value.'  '.$author->display_name;
                    }else{
                       $new_credits[$key] = $value;
                    }
                 }
     
            }
        }
        if($flag)
            $credits = $new_credits;
     
        return $credits;
    }
     
    #2764
    DrSchmenge
    Spectator
    Thanks, I'll give it a try & get back to you.
    #3334
    DrSchmenge
    Spectator
    That doesn't help - it does not customize $link. I don't need to customize the button label. I see $match[]=$link.'#'.$membership_id; and I want to replace <span style="line-height: 1.5;">'#'.$membership_id;' in the url with'/'</span>.$author->display_name<span style="line-height: 1.5;">;`. Make sense now?</span>
    #3335
    DrSchmenge
    Spectator
    That doesn't help - it does not customize $link. I don't need to customize the button label. I see $match[]=$link.'#'.$membership_id; and I want to replace '#'.$membership_id; in the url with '/'.$author->display_name;. Make sense now?
    #3342
    DrSchmenge
    Spectator
    I finally figured it out - though I can't give you much credit for it. If you had been able to tell me that I should look at the bp_course_get_course_credits function in the first place you would have saved me - and you - a lot of time. I am thankful that you made bp_course_get_course_credits a pluggable function, so I customized it, made a plugin, activated it and BOOM. Done.
    #3444
    Anshuman Sahu
    Keymaster
    Ok marking it as resolved and closing the topic .
Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Where is the_course_button defined?’ is closed to new replies.