Need help with a few small Coursepress tweaks & one bigger issue

Hello! I’ve got a couple of small things that shouldn’t be hard to tweak but I don’t know how to do them :slight_smile:

Here they are…

– On the bottom of the articles page it says “Details” and that takes you to details on the last article. Could we get rid of that button since it is only on the last article, and they can access details just by clicking on the article anyways.

– Can we remove the save progress and exit button on the bottom of the units section?

– Could we Add a home button at the very bottom of the screen that will take us back to the home page?

Now for the bigger issue…

Currently things are set up with Membership 2 handling recurring payments. However there seems to be a gap between the two plugins, which is this.

When adding a course, you have the option to choose “Who Can Enroll.” The dropdown has Manually added, Anyone, Anyone with a pass code and anyone who completed a past article. Manually added is not possible because of the expected volume of students. Anyone would not work because they are supposed to pay. Anyone with a pass code could work if we emailed users the pass code via Membership 2’s email system, however if they cancel their subscription they would still have the pass code and could take courses regardless. Of course the prerequisite course option wouldn’t work because it isn’t that kind of a site.

The goal is so students can read the details about the course on the details page, but when they try to sign up it should prompt them to register if they haven’t logged in OR force them to log in with their paid account.

Hopefully that makes sense, and sorry for writing a novel here. :slight_smile:

  • Adam Czajczyk
    • Support Gorilla

    Hello Meredith,

    I hope you’re well today and thank you for your question!

    – On the bottom of the articles page it says “Details” and that takes you to details on the last article. Could we get rid of that button since it is only on the last article, and they can access details just by clicking on the article anyways.

    I accessed your site and took a look at few randomly selected articles (courses) but I couldn’t see that “Details” link. Could you please provide me with an URL where I could see it?

    – Can we remove the save progress and exit button on the bottom of the units section?

    This CSS code does the job:

    #save_student_progress {display:none;}

    I already added it to your site at the very end of CSS code on “Appearance -> CSS” page in site’s dashboard.

    – Could we Add a home button at the very bottom of the screen that will take us back to the home page?

    Yes. Please go to the “Appearance -> Menus” page in your dashboard and create a new menu. Put all the links there that you’d like to show in your site’s footer (including “Home” link) and then save a menu. Then switch to “Menu Locations” tab and assign this new menu to the “Footer Menu” location.

    Now for the bigger issue…

    Currently things are set up with Membership 2 handling recurring payments. However there seems to be a gap between the two plugins, which is this (…:wink:

    CoursePress requires student to be registered and logged in user of the site, otherwise courses are not available so it will force students to register/login anyway. However, your students are supposed to pay and you’re already using Membership 2 Pro plugin.

    The solution is to first setup courses’ “Who can Enroll” option to “Anyone” so – initially – courses would be available to anyone that’s willing to enroll.

    Then, please go to “Membership 2 -> Memberships” page and create your paid membership(s). It may be a single membership or multiple memberships in case you’d like to charge students separately for each course.

    After this, please enable the “Individual Custom Posts” add-on on “Membership 2 -> Add-ons” page and finally – on “Membership 2 -> Protection Rules -> Custom Post Type Items” you’ll find multiple items of types: course, module, unit. Assign selected memberships to them (you’ll be able to find out which course/module/unit belongs to which course by its name/title). Most likely you will want to protect only “module/module_response” and “unit” posts because you’d like to let students see courses’ descriptions.

    This way your courses will be protected by membership of your choice and after a student registers and logs in he/she should be able to see course description and even enroll for the course but when decide to “start learning” they’ll be presented with membership signup page. They’ll need to click on “signup” button and make a payment and after payment goes through they’ll be automatically given an access to the course.

    Then, each time they login that membership will already be applied to their accounts and they keep their access to that course.

    I hope that helps!

    Best regards,

    Adam

  • Meredith
    • The Bug Hunter

    Thank you so much for your in-depth reply. This really helped.

    Despite your fantastic directions my thick-headedness is getting in the way… I can’t seem to find how to protect an entire custom post type in the “Membership 2 -> Protection Rules -> Custom Post Type Items” area, rather only how to do that on each individual course.

    Again, thank you so much :slight_smile:

    P.S. the Details button is at the bottom of this page… http://physicaltherapy.thejournaljunction.com/courses/

  • Predrag Dubajic
    • Support

    Hi Meredith,

    When you go to Membership 2 > Add-on check if the "Individual Custom Posts" add-on is active, if it is you can protect individual posts, but if you turn that off you can protect entire custom post type :slight_smile:

    P.S. the Details button is at the bottom of this page… http://physicaltherapy.thejournaljunction.com/courses/

    About this one, I see that you have some CSS added to move these buttons, other buttons are loaded on the page as well but are hidden by the next course on list, this is the code causing that:

    button.apply-button,
    a.apply-button,
    span.apply-button.apply-button-finished,
    input.apply-button[type="submit"],
    input.apply-button[type="button"] {
    float: left !important;
    margin-top: 30px;
    width: 250px !important;
    }

    When that code is off all buttons are back in place:

    If you want to hide all Details buttons from courses list page try using something like this:

    .course-archive .apply-button-details {
    display: none;
    }

    Best regards,

    Predrag

  • Meredith
    • The Bug Hunter

    Okay so I have been able to set the custom post types of Module, Module_response and Unit as protected.

    Now as a guest when I go to the Articles page, I click on the article, click the “Start Learning” button, get a congratulations message but then go to the Units page. I can then click on the units but get a blank screen, no kind of explanation even though I have protection messages set up. What’s even weirder is if I go back to the Units page then it adds another percent sign by the percent of the article completed so it says 0%%.

    What am I doing wrong that the protection message is not showing? I do not want guests to even see the units page?? :O

    Please help, thank you. And Predrag Dubajic thank you for your input, my problem is if I remove that code then the buttons on the home page get strange. I’m just out of my league when it comes to CSS ha ha :slight_smile:

  • Predrag Dubajic
    • Support

    Hi Meredith,

    Can you try going to Membership 2 > Add-ons and enabling URL Protection add-on.

    After that in protection rules protect the URL to your units/sessions page like this:

    yourdomain.com/courses/name-of-article-here/sessions/

    As for the CSS, you can leave your code there and just add the last snipped from my previous comment and that will hide the button from courses page but it will not affect other pages.

    Best regards,

    Predrag

  • Predrag Dubajic
    • Support

    Hi Meredith,

    Apologies for the delay here I was away for the weeknd.

    Unfortunately I don’t have access to your files and I was actually asking for the code from that mu-plugin so I could check if it can be affecting anything.

    Can you please give me the thread URL as it should have the code in there?

    Best regards,

    Predrag

  • Meredith
    • The Bug Hunter

    This is the code in the file…

    <?php

    add_action( ‘wp_footer’, ‘multiple_column_course_list’ );

    function multiple_column_course_list() {

    ?>

    <script type=”text/javascript”>

    jQuery(document).ready(function() {

    jQuery( “.course-list-item” ).addClass( “vc_col-sm-4” );

    });

    </script>

    <?php

    }

  • Predrag Dubajic
    • Support

    Hi Meredith,

    Thanks, however the code simply adds one more class to course items and it shouldn’t be affecting this in any way.

    I did some additional tests on your site and still couldn’t find any cause of this.

    Is it possible for you to create staging site and provide me with FTP access to it so we can try out debugging there without the fear of affecting your current site?

    You can send us your details using our contact form https://premium.wpmudev.org/contact/ and the template below:

    IMPORTANT: Make sure you select “I have a different question” for your topic so it doesn’t go back to forums – this and the subject line ensure that it gets assigned to me.

    Subject: “Attn: Predrag Dubajic

    – WordPress admin username

    – WordPress admin password

    – Login url

    – FTP credentials (host/username/password)

    – Link back to this thread for reference

    – Any other relevant urls

    Best regards,

    Predrag

  • Predrag Dubajic
    • Support

    Hi Meredith,

    Thanks for sending in those details, I did couple of more tests and tried reinstalling CoursePress, M2, updated WP, disabled plugins, and so on, but nothing helped.

    Only way to see it working properly on your site is by switching from CoursePress theme to default WP one.

    I’m still unable to replicate this on my installation and I must say I’m pretty lost here so I will need to call in some of our second level support dev guys to have a look at this and see if they have any more ideas what might be causing it.

    Best regards,

    Predrag

  • Panos
    • SLS

    Hi Meredith ,

    I’m not sure, but it seems the ftp user you sent to Predrag doesn’t have sufficient permissions as I don’t see CoursePress plugin files in plugins directory nor can I see it’s settings when logging in admin.

    Could you please try using same credentials you sent and let me know if I am mistaking.

    Waiting for instructions :slight_smile:

    Thanks!

    Panos

  • Meredith
    • The Bug Hunter

    I have logged in with the credentials and am able to see the courepress plugin in the plugins directory. Please make sure in FTP that you have entered the subdomain “physicaltherapy,” as the build is not located at the root but rather public_html -> physicaltherapy -> stage.

    You will find the Coursepress settings located underneath “JJ Articles” in the admin dashboard; it was renamed for the client.

    Hope this helps!

  • Meredith
    • The Bug Hunter

    I have logged in with the credentials and am able to see the courepress plugin in the plugins directory. Please make sure in FTP that you have entered the subdomain “physicaltherapy,” as the build is not located at the root but rather public_html -> physicaltherapy -> stage.

    You will find the Coursepress settings located underneath “JJ Articles” in the admin dashboard; it was renamed for the client.

    Hope this helps!

  • Panos
    • SLS

    Hi Meredith,

    You were right! Didn’t see that :slight_smile:

    What seems to be happening is that M2P plugin can’t do the redirect when the theme contains a specific template. In this case you are using the CoursePress theme which contains a template for single units. Although the content is being protected (it’s not visible), it won’t redirect.

    The file that is being used for single units is file : wp-content/plugins/coursepress/themes/coursepress/single-unit.php

    I have edited this file so it should display the Protected message that has been set at the admin menu > Membership > Settings > Protection messages page.

    I would recommend to copy the entire theme folder from the wp-content/plugins/coursepress/themes folder directly to your wp-content/themes directory so it doesn’t get overridden with any updates.

    Another solution would be to not use this template file at all by removing it. This way it will use default single.php page and should not have a problem with the redirection.

    Let me clear that, with the changes I have made at the single-unit.php file, the page isn’t redirecting but it does show the protection message. There’s nothing wrong that I can think of with that. But by deleting (of renaming) that file, the user will be redirected to the Protected Content virtual page which is default behavior of M2P.

    Hope I didn’t confuse you to much here :slight_smile: Please let me know if you need further explanation!

    Kind regards,

    Panos

  • Meredith
    • The Bug Hunter

    Hi Panos, thanks for looking into this for me. I don’t know if its just me but I am still unable to see any kind of protection message. And I really don’t want the protection message to come up on the single unit page (http://physicaltherapy.thejournaljunction.com/courses/name-of-article-here/sessions/read-the-article-here/page/1/ for example) as much as I do the entire unit page that has the list of all the units.

    Sorry if that sounds confusing. Basically the user shouldn’t even be able to click on any of the individual units, the units page (i.e. http://physicaltherapy.thejournaljunction.com/courses/name-of-article-here/sessions/) should be protected itself.

    Thanks!

  • Panos
    • SLS

    Hi Meredith ,

    I had applied the changes at the stage subdirectory that’s why you couldn’t see that message in the link above :slight_smile:

    I totally understand showing protection message on unit archive page. I have uploaded a new theme, Coursepress WPMUDEV, in your wp-content/themes folder which is using the default archive.php instead of the archive-unit.php. Any future changes we do there will not be overridden by updates. I haven’t tested it in your installation since I have admin access only for the stage sub directory site.

    So could you activate it and check how it works for you? In case you notice any issues with this theme could you please provide admin credentials for this site too? You can provide them by replying to the email you sent to Predrag Dubajic !

    Thanks!

    Panos

  • Meredith
    • The Bug Hunter

    Hi Panos,

    I have checked into this and for some reason I am getting error messages when logged in or when logged out and trying to see units. The first attachment of what it looks like when I am logged in as administrator, the second one when I am a guest.

    Admin credentials for the site are the same as for the staged site, thank you! :slight_smile:

    Thanks!!

  • Milan
    • WordPress Wizard

    Hello Meredith

    Hope you are well today and thanks for asking us. :slight_smile:

    First of all, you don’t need to worry about it as those are not error messages but just warnings. :slight_smile: You can disable those warning by adding this line,

    error_reporting( 0 );

    at the end of wp-config.php file.

    Could you please do that and let us know how it goes ?

    Kind Regards,

    Milan

  • Panos
    • SLS

    Hi Meredith ,

    This was a result off switching to using the default archive page instead of theme’s archive-unit.php template file.

    I restored to theme’s so it should display these style effects but this way the Membership plugin rules won’t work.

    I tried using some hooks of plugin and force to redirect to protected content page but each time I faced several issues in my test site and decided not to apply these modifications on your site.

    So the best option available is to enable the URL Protection add-on of Membership as Predrag already mentioned and insert specific url rules.

    To do so :

    1. Go to admin menu > Membership 2 > Add-ons and somewhere close to the bottom of that page you will see the URL Protection add-on.

    2. Please activate it

    3.Then go to admin menu > Membership 2 > Protection Rules where you will see a new tab “URL Protection”

    There you can add the urls you need to restrict access. You will need to repeat the sessions and units page for each course.

    Thanks!

    Panos

  • Panos
    • SLS

    Hey Meredith ,

    I had been re-thinking this and this seems to be working in my testing sites:

    add_filter( 'the_content', 'wpmudev_content_filter' );

    function wpmudev_content_filter( $content ){

    if(strpos($_SERVER['REQUEST_URI'], 'sessions') == true && !current_user_can( 'manage_options' ) ){
    $allowed = false;

    if( class_exists('MS_Controller_Shortcode') ){

    if( is_user_logged_in() ){

    $user_id = get_current_user_id();
    $member = MS_Factory::load( 'MS_Model_Member', $user_id );
    $memberships_ids = ( array ) $member->get_membership_ids();
    $content .= '$memberships_ids: ' . print_r( $memberships_ids,true );
    if( is_array( $memberships_ids ) && !empty( $memberships_ids ) ) $allowed = true;

    }

    if( ! $allowed ){
    $m_contoller_sh = new MS_Controller_Shortcode;
    $content = __( $m_contoller_sh->protected_content( array() ) );
    }
    }

    }

    return $content;

    }

    You can insert it in your mu-plugin. I already tried but it made no difference so I suppose there is some kind of caching enabled. You’ll need to deactivate any sort of cache in order to check if it works :slight_smile:

    Thanks!

    Panos

  • Meredith
    • The Bug Hunter

    Wow that worked! I put that into the plugin I had already in there and it is now showing the circles.

    I may not have put it in right though because now I see all this at the bottom of the site…

    add_filter( 'the_content', 'wpmudev_content_filter' ); function wpmudev_content_filter( $content ){ if(strpos($_SERVER['REQUEST_URI'], 'sessions') == true && !current_user_can( 'manage_options' ) ){ $allowed = false; if( class_exists('MS_Controller_Shortcode') ){ if( is_user_logged_in() ){ $user_id = get_current_user_id(); $member = MS_Factory::load( 'MS_Model_Member', $user_id ); $memberships_ids = ( array ) $member->get_membership_ids(); $content .= '$memberships_ids: ' . print_r( $memberships_ids,true ); if( is_array( $memberships_ids ) && !empty( $memberships_ids ) ) $allowed = true; } if( ! $allowed ){ $m_contoller_sh = new MS_Controller_Shortcode; $content = __( $m_contoller_sh->protected_content( array() ) ); } } } return $content; }

    Thank you so much for your help, and putting in the extra thought. I really appreciate it. :smiley:

  • Panos
    • SLS

    Hi Meredith,

    Of what I see you have a register page where there is a custom table with membership plans. This page appears to visitors (users not logged in).

    When users are logged, the Membership plugin redirects them from the register page to the memberships page. This is by design so logged in users don’t see the registration page but instead can see available memberships to subscribe.

    I would recommend to change you menu so it doesn’t contain the registration link when user is logged in. You can check out this plugin https://wordpress.org/plugins/baw-login-logout-menu/ which adds login/ logout and registration links to menu.

    Or if you prefer more control you can try adding the following snipped at your theme’s functions.php file:

    function wpmudev_add_registration_link_to_menu( $items, $args ){

    if( is_admin() || $args->theme_location != 'primary' )
    return $items;

    $the_reg_page = 'ID or Slug of registration page';

    if( is_user_logged_in( ) )
    $link = '<a href="' . esc_url( get_permalink( $the_reg_page ) ) . '" title="' . __( 'Register' ) .'">' . __( 'Register' ) . '</a>';

    return $items.= '<li id="wpmudev-reg-item" class="menu-item menu-type-link">'. $link . '</li>';
    }

    add_filter( 'wp_nav_menu_items', 'wpmudev_add_registration_link_to_menu', 10, 2 );

    Thanks!

    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.