change register link in marketpress when forced login

Hi Guys, if I choose force login in the settings a new button appears with the Register Now to Shop button... how can I change the registration link of that button?

  • Vaughan
    • Support/SLS MockingJay

    Hi @bePresence,

    The register link points at the WP registration URL

    Where do you want it to go?

    You can change the registration_url using a filter in your theme functions.php

    function my_reg_page( $register_url ) {
        return home_url() . '/register/';
    }
    add_filter( 'register_url', 'my_reg_page' );

    The above would change the registration url to point to domain.com/register/

    But it would change it globally for the whole site.

    Do you just want it changing on the mp page, or?

    Thanks

  • Jack Kitterhing
    • Code Norris

    Hi there @BePresence,

    Hope you're well today and thanks for your question! :slight_smile:

    Open up marketpress/marketpress-includes/template-functions.php and go to line 741. You'll see this code

    $content .= '</td>';
    				$content .= '<td class="mp_cart_or_label">' . __('or', 'mp') . '</td>';
    				$content .= '<td class="mp_cart_checkout">';
    				if ($mp->get_setting('force_login'))
    						$content .= apply_filters('register', '<a class="mp_cart_direct_checkout_link" href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register Now To Checkout &raquo;', 'mp') . '</a>');
    				else
    						$content .= '<a class="mp_cart_direct_checkout_link" href="' . mp_checkout_step_url('shipping') . '">' . __('Checkout Now &raquo;', 'mp') . '</a>';
    				$content .= '</td>';
    				$content .= '</tr>';
    				$content .= '</tbody>';
    				$content .= '</table>';
    		}

    We're specifically looking at this code

    $content .= apply_filters('register', '<a class="mp_cart_direct_checkout_link" href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register Now To Checkout &raquo;', 'mp') . '</a>');

    You can see there it uses the site_url function to get the URL of your site and then appends the wp-login.php?action=register to that, you can change that as needed.

    Please note any changes you make to core files would be lost on a update.

    Thank you!

    Kind Regards
    Jack.

  • Jack Kitterhing
    • Code Norris

    Hi there @BePresence,

    Hope you're well today, you could try overwriting the checkout template, copy and paste the code from the checkout template into mp_cart.php

    And then place that in your themes root folder. :slight_smile:

    Or you could try something like this in your functions.php of your theme.

    add_filter('register', 'incsub_custom_mp_reg');
    	function incsub_custom_mp_reg($link) {
    		if(!is_user_logged_in()) {
    			$link - '<a href="' . site_url('your-login.php') . '">' . __('Register') . '</a>';
    		}
    
    		return $link;
    	}

    Thanks!

    Kind Regards
    Jack.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.