Support » Plugin: Restricted Site Access » Exclude registration page

  • Resolved xavatar94

    (@xavatar94)


    Hello,

    Sorry for my english, i’m french.
    I have read some post but i dont understand wich exactly code i need to exclude the registration Page (and where add this code)

    If someone can help me ?
    Thank you for your reply.

    • This topic was modified 3 months, 2 weeks ago by xavatar94.
    • This topic was modified 3 months, 2 weeks ago by xavatar94.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Tung Du

    (@dinhtungdu)

    Hi @xavatar94,

    Your English is totally okay :).

    To solve your problem, you can edit and add the following snippet to your theme’s functions.php file or a custom plugin.

    Assume that you enabled pretty permalink and the registration page URL is example.com/register.

    add_filter( 'restricted_site_access_is_restricted', function( $is_restricted, $wp ) {
    	if( 'register' === $wp->request ) {
    		return false;
    	}
    	return $is_restricted;
    }, 10, 2 );

    I added this code so that access was enabled access to password reset and forgot username as well.

    edit: just realized I should have qualified the profile links I added access to are for the WP-Members Membership Plugin. I have been bouncing back and forward between them testing are realized I was confusing functionality between the two. 🙂

    add_filter( 'restricted_site_access_is_restricted', 'zgwd_login_override', 10, 2 );
    function zgwd_login_override( $is_restricted, $wp ) {
        // check if page allowed
        if ( 'registration' === $wp->request ||
    	 'profile?a=pwdreset' === add_query_arg(array($_GET), $wp->request) || 
    	 'profile?a=getusername' === add_query_arg(array($_GET), $wp->request) ) {
            return false;
        }
        return $is_restricted;
    }
    • This reply was modified 3 months, 1 week ago by ZeroGravity.
    • This reply was modified 3 months, 1 week ago by ZeroGravity.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.