• Resolved tw

    (@guts)


    Yo Thomas,

    I wanted to increase the number of courses displayed on the student dashboard.
    Finally found the code but don’t want it to blow up when lifterlms updates.

    I’ve got a separate snippets plugin but the code I’m popping in there isn’t doing the trick.

    It’s found on line 158 of LOCATION: lifterlms/includes/class.llms.student.dashboard.php
    I’ve changed ‘3’ to ’30’

    /**
    * Callback to output main dashboard content
    * @return void
    * @since 3.0.0
    * @version 3.0.0
    */
    public static function output_dashboard_content() {

    $student = new LLMS_Student();
    $courses = $student->get_courses( array(
    ‘status’ => ‘enrolled’,
    ‘limit’ => apply_filters( ‘llms_dashboard_recent_courses_count’, 30 ),
    ) );

    llms_get_template( ‘myaccount/dashboard.php’, array(
    ‘current_user’ => get_user_by( ‘id’, get_current_user_id() ),
    ‘student’ => $student,
    ‘courses’ => $courses,
    ) );

    }

    I’ve made the change in the actual .php page. It works…but how can I make this code update stick without it changin the next time lifterLMS updates. it’s not in the “functions” page and I’m now out of my scope of understanding.
    I hope you can help.
    Thanks
    Tim

Viewing 10 replies - 1 through 10 (of 10 total)
  • I suspect you’ll like the LifterLMS helper plugin then. You can add in your code changes & when the plugin updates, it should all remain intact (similar to a child theme)

    https://lifterlms.com/docs/lifterlms-helper/

    Let me know if it works for you?

    Loralee
    (customer support team – LifterLMS)

    Thread Starter tw

    (@guts)

    Hi Loralee,

    I tried the adding the code from above using the liftermls-customization.php method: (that broke my site)

    I also tried adding the entire code from that page (lifterlms/includes/class.llms.student.dashboard.php) using the liftermls-customization.php method.
    Broke the site again.

    **** NOTE **** I don’t think this is “functions.php” content. I’m I correct on this? That is what I’m asking…I don’t know where to place this change in code.
    For now I’ve just updated the ORIGINAL (lifterlms/includes/class.llms.student.dashboard.php) file but I know I’ll get burned on the next lifter update.

    I also just tried the override template method… suggested here…
    https://lifterlms.com/docs/how-do-i-add-custom-code-to-lifterlms-or-lifterlms-launchpad/

    I created the new directory but that didn’t work either. my changes didn’t take.

    I need some help please.

    I believe this is because the change I want to make is in the ASSETS folder an not the templates folder. I don’t think this is a “functions” modification.

    Thread Starter tw

    (@guts)

    Hi Loralee,

    Just a note to reactivate this thread.
    Thanks
    Tim

    @guts,

    You’ll want to add this (and this alone) to a functions.php file or to the customization plugin

    
    function my_dashboard_recent_courses_count( $count ) {
       return 30;
    }
    add_filter( 'llms_dashboard_recent_courses_count', 'my_dashboard_recent_courses_count' );
    

    Hope that helps,

    Thread Starter tw

    (@guts)

    Hi thomas

    thanks for the reply,
    I entered the code just you suggested
    It did not work.

    I put back the original ‘class.llms.student.dashboard.php’ file in the ‘lifterlms/includes’ directory (that code displays 3 courses only) so it went back to normal.
    then entered your code as is in the customization plugin.

    here’s the fatal error it shows.
    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /homepages/40/d406260191/htdocs/wp-ytp-courses/wp-content/plugins/lifterlms-customizations-master/lifterlms-customizations.php on line 53

    on one of my logged in accounts, I’m a member and have access to all courses, so when I had the “return 30” .php file uploaded… I had all 9 of my courses visible on my dashboard. With this new code. only 3 show up. not 9.

    got another suggestion?
    besides starting from scratch and creating a child theme, or having to manually replace the ‘class.llms.student.dashboard.php’ every time there is a lifter update?
    thanks
    Tim

    Thread Starter tw

    (@guts)

    I think the problem thomas is that this function command controls the THEME which is launchpad btw. but the file that I’m working with is within the lifter plugin itself….NOT the theme.
    I don’t know where to put this change of code?

    Not sure if that’s the prob but might be something to consider. please advise

    lifterlms/includes/class.llms.student.dashboard.php

    Thread Starter tw

    (@guts)

    Any ideas Thomas?

    Hey @guts,

    I completely understand the problem and my solution is the correct one, you must’ve added the code in the wrong way…

    Here’s a link to a version of the customization plugin main file that will work: https://gist.github.com/thomasplevy/bfb996b39fa97e832a215ff3cceee4cc

    Take care,

    Thread Starter tw

    (@guts)

    I don’t know what the hell I was doing. I swear I tried this UMPTEEN times.
    I ended up re-installing the customization plugin and that code worked.
    Thanks for the push Thomas. I got it solved!
    Much appreciated.
    Tim

    you’re welcome

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘display number of courses on dashboard’ is closed to new replies.