ZeroGravity on "[Plugin: Simple Membership] Redirect / popup if not logged in"

ساخت وبلاگ

I was wanting to do the same thing. We added the plugin to an existing site and wanted to protect the whole site. There is only one access level so this made it easier to implement, but there is another function that tests if a user has access to a page which could be used to extend what I have written.

We didn't want to go to every page and update the protection and the user updating the site didn't want the "pressure" :) of remembering to check the protection settings.

I put this code in the theme functions.php and it seems to be working from the testing I have done.

//* Redirect a user who isn't logged in
add_filter( 'pre_get_posts', 'zgwd1010_rediredt_user' );
function zgwd1010_rediredt_user() { if( !SwpmMemberUtils::is_member_logged_in() && !is_page( array( 'membership-login', 'membership-join' )) ) { wp_redirect( 'http://www.mydomain.com/membership-login' ); exit; }
}

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 226 تاريخ : شنبه 29 خرداد 1395 ساعت: 1:13