[CoursePress Pro] Pre Requisite Course Button not functioning

Hello superheroes,

We're experiencing a very strange problem with the course join button - the contextual one that appears on the course details page.

To help give context to the problem, we have two courses: Course A and Course B. Course A is a prerequisite to Course B.

My understanding is that if users go to Course B before completing Course A they should see the 'pre requisite required' (or similar) button appearing on the course details page, which should direct them to Course A's page.

At the moment, new users are experiencing a strange problem. If they visit Course B, they see the "Pre Requisite Required" button instead of "sign up and start learning". The button directs them to the course details page - the page they're already on!

If they are logged in and view Course A, they see a 'Details' button page which, again, just reloads the same page, rather than a the start / begin learning button (or similar)

We're absolutely stumped by this! The enrollment settings for Course A are 'any registered user'. I feel like there might be something silly we're missing here...! Any advice you can give would be gratefully appreciated.

Many thanks again!

Rob

  • Predrag Dubajic

    Hi Rob,

    Hope you're doing well today :slight_smile:

    Could you please grant us support access so we can check your CoursePress settings and how exactly it behaves to better understand this?

    To enable support access you can follow this guide here:
    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5

    Please respond in this ticket once access is granted.

    Best regards,
    Predrag

  • Predrag Dubajic

    Hi Rob,

    Thanks for granting access, I had a look at your courses and it seems that the issue here are your customizations made to the theme or course, I'm not sure how this is actually made on your end.

    By default, when you go to Course B that requires Course A the enroll button does change to "Pre-requisite Required" but it also gets disabled, it shouldn't be clickable at all, like it is on your end.

    Instead of the "Who can Enroll" part it should show a link to your required course, and on that course, it should show regular Enroll button.
    Here's a quick video of the default behavior of the process:
    https://monosnap.com/file/UsSz3KsbNBWy0Qx57DiVC8zEtQx3D0

    I would suggest switching to default CoursePress theme and check if the behavior is correct on your site after that so we can indeed see if it's due to your customizations that this is happening.

    Best regards,
    Predrag

  • Martin

    Hi Predrag,

    I see! That makes sense.

    The customization we're using is basically just a custom single course page template that uses the join_course_button shortcode, so it's the shortcode that's generating the broken button. Should there be something in the button shortcode that disables the generation of this button? At least if we can stop the broken button being displayed and prevent 'Details' from showing up, we can perhaps add some kind of condition to our template that shows the 'Pre requisite course required' link if applicable.

    It does seem to work on the default coursepress template, but this does still pose a problem with our customization. I realise that obviously it's because of the changes we've made and therefore possibly out of your scope, but if here any pointers you can give us on how to resolve this we would be immensely grateful!

    Thanks so much for your ongoing support! I really do appreciate it.

    Rob

  • Adam Czajczyk

    Hello Martin

    Thank you for your response.

    I checked your custom template (content-course.php) and tried to replicate that on my end, using shortcode in that exact way as it's used on your site. I got a bit "mixed results" but I'd like to ask you to try two things, please:

    1. In a [course_join_button] shortcode you're using "list_page" attribute. That attribute is actually supposed to provide access to the details of the course that the user is currently looking at. However, it should be yest to "true" rather than "yes". Could you please try changing "yes" value to "true" then and see what happens then?

    2. If that doesn't help, try removing that entire "list_page" attribute all together and see if that helps.

    I didn't want to make any changes via back-end "Appearance -> Editor" to the files as this is always a risk, so I wasn't able to check so please give it a try and let me know if that changes anything.

    Kind regards,
    Adam

  • Martin

    Hi Adam,

    Really appreciate you coming back to us - unfortunately I think you might be looking at the wrong template there. content-course.php isn't currently active or being used for anything - it's just there because we forgot to delete it! For whatever reason, our theme or CoursePress isn't loading it as a template for the appropriate page. We were experimenting with which templates controlled which virtual page, and content-course didn't appear to affect anything on our end. I think all the content in that file is CoursePress default.

    I did try your suggestion in that file, just to see if there was a weird conflict and nothing changed. I then deleted the template and still nothing changed as far as I can see.

    The template we're having issues with is single-course.php. Do you think you could have a peek in there and see if there's an issue?

    The code we're using to generate the button is <?php echo do_shortcode('[course_join_button enroll_text="Continue" signup_text="Sign up and enroll!" list_page="true" class="button-override"]'); ?>

    I'm still scratching my head over this one!

    Thanks so much again!

  • Adam Czajczyk

    Hello Martin

    Thank you for your response and explanation.

    You're right, I did look at the wrong template, I'm sorry for the mistake. However, it's still related to the shortcode. I did some more testing on my end and the shortcode will work the way it does "natively" if you actually remove the list_page="true" attribute entirely.

    It will then show "Sign up and enroll" button (working) on a pre-requisite course and on other courses - that require pre-requisite course - it will show "Pre-requisite Required" button instead. That button will not do anything though (just like it doesn't with a default CoursePress theme) so there's a need to add additional information.

    That can be added by outputting yet another shortcode

    [course_enrollment_type]

    You can, of course, use "do_shortcode()" function for that and it will show a message "Who can Enroll" where in case of a course that requires pre-requisite course to be completed first, it will say "Students need to complete SOMETHING first", where SOMETHING is the name of the pre-requisite course (an active link to that course).

    This shortcode can also take additional attributes (See "CoursePress Pro -> Settings -> Shortcodes") so you can adjust the message it gives.

    Best regards,
    Adam

  • Martin

    Hi Adam,

    Once again, appreciate your thorough response. I understand the button's functionality a little more now.

    However, even removing the list_page attribute from the shortcode is still causing the pre requisite course to show logged in users who have not yet enrolled a 'Details' button rather than the enrol now button. We can get around this by manually adding users to the course but it's not an ideal situation as we have many users trying to access the course.

    Is there another attribute I'm missing here?

  • Predrag Dubajic

    Hi Martin,

    I tried installing your child theme on my end and it works fine there, when I'm logged in but not enrolled it shows "Continue" as it's defined in the code, and when I'm logged out it shows "Sign up and enroll!", again as it should.

    So it seems that this is configured correctly but there's something else on your site that's changing this element.
    And it's not just that the text is different, the entire button structure is changed, when I inspect the page on my end it uses button tag while on your site it uses link, here's what I'm referring to:

    Do you have any other scripts or something like that which could be affecting the code that is shown on the single course page?

    Best regards,
    Predrag

  • Martin

    Hi Adam,

    That's really strange. I'm looking into it but I can't see any likely candidates - there's no JavaScript that appears to be interfering with the output that I can see, and I've deactivated a few plugins that might have been likely culprits but nothing worked.

    However, when inspecting the console and clicking the details button - we get this error flash up briefly before the page reloads. Could this be a clue?

    I'm going to check again through some other functions files to see if there's anything that might be messing with the code.

    Thanks again for all your help so far!

  • Predrag Dubajic

    Hi Martin,

    I was doing some further testing and it seems that the issue is that some of your plugins are not responding well to Asset Optimization in Hummingbird, so when I disabled Minification for all the files and cleared the cache it started showing correct button.

    I would suggest enabling minification for your files one by one until you figure out which one is causing the issue and then leave that file un-minified.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.