WordPress.org

Forums

Membership 2
[resolved] Registration and Login page (8 posts)

  1. WPPaton
    Member
    Posted 1 year ago #

    Hello there just started using membership. What I am trying to create is quite simple. I have one tab on a page which is protected for non paying members (classified level 1). What I want is when you click on that tab something would come up indicating this is protected area please either login or register.

    So far I have created two levels visitors and level 1. I have a page that comes up when they click on that tab to get access indicating this is a protected page.

    The item I can't figure out is there short code I can use on that page so that both a login form and a registration form would show up. Once that is created they would be redirected to that protected content page.

    To see what I mean you can go to http://www.patonplace-testsite1.ca and then click on the tab on the far right called Evolution CDC. Hopefully this makes sense if I am not clear feel free to post something here.

    http://wordpress.org/plugins/membership/

  2. WPMU DEV
    Member
    Posted 1 year ago #

    Hi @WPPaton,

    I hope you are well today and thank you for your question.

    You can use [subscriptionform] membership plugin shortcode to display subscription form on the page but there currently there isn't any shortcode to display login form, you can create a [login-form] shortcode to display login form by adding following code in functions.php file of your theme.

    add_shortcode( 'login-form', 'my_login_form_shortcode' );
    /**
     * Displays a login form.
     *
     * @uses wp_login_form() Displays the login form.
     */
    function my_login_form_shortcode( $atts, $content = null ) {
    
    	$defaults = array(		"redirect"				=>	site_url( $_SERVER['REQUEST_URI'] )
    						);
    
    		extract(shortcode_atts($defaults, $atts));
    		if (!is_user_logged_in()) {
    		$content = wp_login_form( array( 'echo' => false, 'redirect' => $redirect ) );
    		}
    	return $content;
    }

    Best Regards,

  3. WPPaton
    Member
    Posted 1 year ago #

    so just two questions: 1) Where would I place the shortcode? 2) Would this give both an option to register or login?

    Thanks for your help I appreciate it!

  4. WPMU DEV
    Member
    Posted 1 year ago #

    Hi @WPPaton,

    Thanks for reply.

    1) Where would I place the shortcode?

    You should place the shortcodes in the Protected Content page where you want to display it.

    2) Would this give both an option to register or login?

    Yes, the [subscriptionform] shortcode will display subscription form and the [login-form] shortcode will display login form.

    Best Regards,

  5. WPPaton
    Member
    Posted 1 year ago #

    Tried adding your php code above in the functions.php file of the theme and it broke the website or logging into the back end. Could you take a look to make sure it isn't missing anything?

  6. WPPaton
    Member
    Posted 1 year ago #

    it works but was hoping to get a registration form as well but thanks.

  7. WPMU DEV
    Member
    Posted 1 year ago #

    Hi @WPPaton,

    Thanks for reply.

    Have you used [subscriptionform] shortcode to display registration form? If yes then have you faced any problem or get any error message?

    Best Regards,

  8. Hey there.

    We haven't heard from you in awhile, so I just wanted to check in to make sure all was good.

    This thread was marked resolved, but please, if you still need help then just respond and open it back up. We can then take it from there. :)

    Hope you have a fantastic day!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Membership 2
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic