More than one public page?
-
Is there a way to have more than one public page – or could the children of a public page also be public?
Many thanks, that would make it the perfect plugin for us!
-
A quick fix for you, in the
private_only ()
function, you can add onto Ivan’s code, which looks like this now:if (!is_user_logged_in() && !is_feed() && isset($settings['public_pages']) && $settings['public_pages'] && is_page($settings['public_pages'])) { return; }
Add an
elseif
to it referencing the specific page you want to be public (alter “pagename” below to your page name/id – depending on your permalink settings). It would look like this:if (!is_user_logged_in() && !is_feed() && isset($settings['public_pages']) && $settings['public_pages'] && is_page($settings['public_pages'])) { return; } elseif (!is_user_logged_in() && !is_feed() && is_page('PAGENAME') ) { return; }
Perhaps in the next version it can be set up to have check boxes for each page on the admin screen, which would then loop through Ivan’s code and return if it is a public page?
Hi Joshua,
I tried the code string you indicated above to define a second public access page, but it seems to have caused a fatal syntax error and deactivated the plugin until I removed it. Can anyone assist with this? I need to define one additional public page simply to load in the terms and conditions needed for the registration. To make it more complicated, I’m combining this plugin with Cimy User Extra Fields for organization requirements.
Thanks!
Fallon McCullough
Fallon,
I just double checked this and I had updated my plugin without thinking about it, so I went back in and replaced the
prviate_only()
function inprivateonly.php
with the following (pretty much the same as my last comment, here’s the whole function)://Main Private Only features function private_only () { $settings = get_option( 'po_login_settings' ); $pagelink = get_permalink($settings['public_pages']); /* New Feature, code added by Ivan Ricotti. Thanks */ if (!is_user_logged_in() && !is_feed() && isset($settings['public_pages']) && $settings['public_pages'] && is_page($settings['public_pages'])) { return; } elseif (!is_user_logged_in() && !is_feed() && is_page('page_slug') ) { // <---- replace page_slug with your additional non-private page slug or page ID return; } if (!is_user_logged_in() && !is_feed() && (!is_page($settings['public_pages']) || empty($settings['public_pages']) || $settings['public_pages'] == '')) { auth_redirect(); } }
Are you sure that you have this in the most current version and didn’t update the plugin (thus writing over this custom fix)? You could also try using the page number instead of the slug.
Again, this is a quick fix. I noticed there are some errors on the plugins admin screen, but it doesn’t look like they are related and it doesn’t stop the plugin from working the way I want it to (with two pages public).
The real fix would be if the options available were checkboxes and this function looped through each page, making the
'public_pages'
variable an array.Hope that helps!
JoshuaHi Joshua,
I’ve tried both the page_id and the slug from default and custom permalinks. I’m adding in a java popup window to the Cimy User Extra Fields plugin, which is correctly linking to the Terms and Conditions (tried T&C as both main page and sub page).
At this point, I’ve fixed the syntax and everything looks fine, but the page I’m trying to define as public is still being blocked by the Private Only plugin. Users are being asked to login and it’s kicking back to the login/registration page each time.
Here’s the code I used for the T&C popup:
Click to View Terms and ConditionsHere’s the code in the Private Only main function (which seems to match the code you pasted above, as far as I can tell unless I’m overlooking a misplaced hyphen or something):
//Main Private Only features function private_only () { $settings = get_option( 'po_login_settings' ); $pagelink = get_permalink($settings['public_pages']); /* New Feature, code added by Ivan Ricotti. Thanks */ if (!is_user_logged_in() && !is_feed() && isset($settings['public_pages']) && $settings['public_pages'] && is_page($settings['public_pages'])) { return; } elseif (!is_user_logged_in() && !is_feed() && is_page('ombudsboard.com/?page_id=269') ) { return; } if (!is_user_logged_in() && !is_feed() && (!is_page($settings['public_pages']) || empty($settings['public_pages']) || $settings['public_pages'] == '')) { auth_redirect(); } }
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
So now I’m stuck. When users click on the link to register, then click on the link to the Terms and Conditions, it looks like it’s redirecting to:
https://ombudsboard.com/wp-login.php?redirect_to=http%3A%2F%2Fombudsboard.com%2F%3Fpage_id%3D269&reauth=1but I’m not sure why…
Fallon,
Your
is_page('ombudsboard.com/?page_id=269')
should readis_page('269')
. Try that. I get this to work on my site, but if it doesn’t work on yours try disabling the other plugin and see if it works with the modification – then you can determine if there is a conflict adding to the mess or if it is something else.Joshua
..and, as a follow-up, if that works, you can always add more pages with the same fix (see below as an example). Just be sure you’re using the page-slug (not the url ombudsboard.com/page-slug, just the ‘page-slug’ portion or the page id number only). If you have another form/page that you are loading via the popup, you’ll need to add that as well.
//Main Private Only features function private_only () { $settings = get_option( 'po_login_settings' ); $pagelink = get_permalink($settings['public_pages']); /* New Feature, code added by Ivan Ricotti. Thanks */ if (!is_user_logged_in() && !is_feed() && isset($settings['public_pages']) && $settings['public_pages'] && is_page($settings['public_pages'])) { return; } elseif (!is_user_logged_in() && !is_feed() && is_page('269') && is_page('another_page') && is_page('yet_another_page') ) { return; } if (!is_user_logged_in() && !is_feed() && (!is_page($settings['public_pages']) || empty($settings['public_pages']) || $settings['public_pages'] == '')) { auth_redirect(); } }
Oh my gosh, Joshua, thank you. I was overlooking the scripting. Such a simple error. I cannot thank you enough for this. I’ll check now to make sure the two plugins seem to be working seamlessly together and address the Cimy plugin, if necessary.
Happy to help! Hopefully it works out for you.
For adding more than one additional exception you have to modify the code from Joshua David Nelson as there is a little error in the elseif:
elseif (!is_user_logged_in() && !is_feed()) { if (is_page('269') || is_page('another_page') || is_page('yet_another_page')) { return; } }
- The topic ‘More than one public page?’ is closed to new replies.