Custom Coursepress Pro SignUp Button Redirect to Membership Options Page

I would like to redirect visitors who click on the Signup button to a custom link/page instead of the student registration pop up. The pop up circumvents forced membership by allow registration as a student without first joining with a membership.
30 second Screencast
http://www.screencast.com/t/zkUrVHgx6Hvh

  • Rupok
    • Support Ninja

    Hi Luke Amoresano, hope you had a wonderful day.

    I would like to redirect visitors who click on the Signup button to a custom link/page instead of the student registration pop up

    You can do this by creating a MU Plugin. For creating a mu plugin, create a folder named "mu-plugins" inside your "wp-content" folder. Then inside that "mu-plugins" folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    <?php
    add_action( 'wp_footer', 'change_signup_event' );
    function change_signup_event() {
        ?>
        <script type="text/javascript">
          jQuery(document).ready(function() {
    		jQuery(".apply-box button").removeClass("signup");
    		jQuery('.apply-box form').attr('action', 'https://www.google.com');
          });
        </script>
        <?php
    }

    Please replace "https://www.google.com" with your target URL.
    For getting more idea on mu plugins, you can go through this article: http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Have a nice day. Cheers!
    Rupok

  • Luke Amoresano
    • Design Lord, Child of Thor

    Rupok, thank you. I will do this right now. Question: If I do this on a multi-site, and coursepress is activated on multiple sites on the newtork, will this plugin cause all the coursepress's to go to the same sign up page? Each coursepress installation will have their own unique signup url.

  • Luke Amoresano
    • Design Lord, Child of Thor

    Rupok, fantastic! Your guidance was perfect. The SignUp button now redirects onclick EXACTLY as you said it would. BUT, I still don't know how this will affect future installs of coursepress on the network. Can I use a relative URL such as: /network-login OR /wp-login.php - that way, no matter what site is using Coursepress, the SignUp will to that individuals sites corresponding page..? I guess I will have to try that - get back to you shortly.

  • Luke Amoresano
    • Design Lord, Child of Thor

    I saw this suggestion in a 2014 post... what do you think?

    jQuery( document ).ready( function( $ ) {
    /* Signup redirection */
    $( 'button.apply-button.signup' ).live( 'click', function( e ) {
    e.preventDefault();
    e.stopPropagation();
    window.location = "http://www.google.com/";
    } );
    } );

  • Luke Amoresano
    • Design Lord, Child of Thor

    Here is the page screencast:
    http://www.screencast.com/t/WLz7Ls14

    I currently have an MU Plugin that Rupok helped me with, BUT it no longer works:

    <?php
    add_action( 'wp_footer', 'change_signup_event' );
    function change_signup_event() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function() {
    jQuery(".apply-box button").removeClass("signup");
    jQuery('.apply-box form').attr('action', '/please-login-for-access/');
    });
    </script>
    <?php
    }

    So, I tried to find another solution and stumbled upon an old post here that showed this:

    jQuery( document ).ready( function( $ ) {
    /* Signup redirection */
    $( 'button.apply-button.signup' ).live( 'click', function( e ) {
    e.preventDefault();
    e.stopPropagation();
    window.location = "http://www.google.com/";
    } );
    } );

    I have NOT tried the jQuery - I would rather have your expert advice. Thanks.

  • Ash
    • WordPress Hacker

    Hello Luke

    Please try the following code and remove the old:

    <?php
    add_action( 'wp_footer', 'change_signup_event' );
    function change_signup_event() {
    ?>
    <script type="text/javascript">
    jQuery(function($) {
        $( '.apply-button' ).each(function() {
            $( this ).removeClass( 'signup' );
            $( this ).click( function(e) {
                e.preventDefault();
                window.location.href = '/please-login-for-access/';
            } );
            $( this ).closest( 'form' ).attr( 'action', '/please-login-for-access/' );
        } );
    });
    </script>
    <?php
    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Luke Amoresano
    • Design Lord, Child of Thor

    Ash, thank you. You are EXACTLY correct! I use WP Rocket. I cleared the cache and the MU Plugin you re-wrote works perfectly. I sincerely hope you have a wonderful day and know that you and your colleagues are wonderfully talented and patience with all of us.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.