Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    What is being done on the member homepage? There is an unparsed shortcode on it, so there’s something that is not entirely right there. Could you give me an idea of what is being used on the page to generate it?

    Thread Starter sharon135

    (@sharon135)

    I used your content restriction code to block logged out users from seeing text content, putting code in beginning and end of text content. Also put “more” tag above it. My learning curve is limited on this. Definitely not doing something right. I keep rereading the documents instructions but can’t figure it out. Basically want a redirect to login page when logged out user clicks Member Homepage; and the text content hidden for logged out users. The same for Calendar page.

    FYI… When users log in on the log in page it redirects to Member Homepage.

    Here’s the code layout=

    Welcome to your Member Homepage!
    “more” tag here

    [wpmem_logged_in]
    Feel free to cruise through your WaterStone community website for important documents, calendar, and other links, including our Facebook page, available to you as a Resident Member. We hope you find the website easy to navigate and find what you are looking for. Below are links and some information and alerts we routinely update to your member homepage. We encourage you to log in frequently to stay connected to what’s happening in our community. Feel free to contact us for any questions or inquiries.

    Edit My Information
    Change Password

    HOW IS MY CONTACT INFORMATION USED?…………………etc
    [/wpmem_logged_in]

    Thread Starter sharon135

    (@sharon135)

    Notice the posts on sidebar in Member Homepage when clicking when logged out, the restrict “dialog” is there with log in or registration below. Want on Member Homepage and Calendar to either do that or a simple page redirect to Log in Page. Whichever one works best.

    Plugin Author Chad Butler

    (@cbutlerjr)

    The calendar for sure needs to be redirected. The elements you are seeing are post meta rather than post content. The plugin does not block post meta specifically because dumping all post meta would include things that may possibly still be needed. There are too many possibilities to generically differentiate.

    The member page I don’t think you need to redirect (but you still could to make things easy). I think the issue here is probably how things are specifically set up. I would take a look at how the shortcodes are applied on this page because based on the fact that we can see the closing shortcode unparsed ([/wpmem_logged_in]) suggests that something isn’t correct. It looks to me like the [wpmem_profile] shortcode is being used, but it is nested in the logged in shortcode. Make sure you’re not nesting [wpmem_profile] in the logged_in shortcode. If you have to split up content, do it this way:
    [wpmem_logged_in]This is the opening content[/wpmem_logged_in]
    [wpmem_profile]
    [wpmem_logged_in]This is the closing content[/wpmem_logged_in]

    You can use the wpmem_redirect_to_login() function to redirect these to the login page.

    You’ll need to make sure a login page is created and set in the plugin’s main options.

    add_action( 'template_redirect', 'my_redirect_to_login' );
    function my_redirect_to_login() {
    	$pages = array( 'member-homepage', 'calendar' );
    	if ( ! is_user_logged_in() && is_page( $pages ) ) {
    		wpmem_redirect_to_login();
    	}
    	return;
    }

    It’s probably good to point out the pieces of this.

    First – template_redirect. This action is the last action before headers are sent, so it is the last point at which you can safely redirect a user. It’s better to use this when the conditional logic needs access to things in the post object (which this does – is_page()). The post object is not available earlier with more commonly used actions like ‘init’.

    is_user_logged_in() tells you if the user is logged in.

    is_page() tells you if a given page or array of pages is the current page.

    If the user is not logged in and the page is one of your pages needing redirect, then wpmem_redirect_to_login() is fired.

    Thread Starter sharon135

    (@sharon135)

    I was able to hide the Member Homepage content and put in log in. I wrapped content except header title with [wpmem_form login] xxxx [/wpmem_form login]. And it worked!

    But the calendar still has an issue. This is what I am currently using for Calendar page.
    [wpmem_form login redirect_to=”https://waterstone.celebratingyourjourney.com/calendar/”%5D

    Something is still wrong here. It shows 2 log in fields. And it doesn’t hide calendar (I assume that’s the case from what you stated above regarding “post meta”. I’m going to email All in One Calendar tech people for their input on this.

    Any other ideas are welcomed. Thank you for taking the time to solve this mystery, which is most likely my limited learning curve at this point.

    • This reply was modified 8 years, 2 months ago by sharon135.
    Plugin Author Chad Butler

    (@cbutlerjr)

    I think you may have missed my explanation about why the calendar has unblocked content:

    The calendar for sure needs to be redirected. The elements you are seeing are post meta rather than post content. The plugin does not block post meta specifically because dumping all post meta would include things that may possibly still be needed. There are too many possibilities to generically differentiate.

    The easiest way to handle it is redirect the user to the login (using the code snippet in the previous post)

    Thread Starter sharon135

    (@sharon135)

    Is this the code below you are referring to for the calendar? And is it put in exactly as you have it or do I add something? I did put the code in and it didn’t redirect to login page. It simply created log in and register fields above the calendar that still shows.

    My apologies for my continuing learning curve. FYI…I do have a login/register page (https://waterstone.celebratingyourjourney.com/log-inregister/).

    add_action( ‘template_redirect’, ‘my_redirect_to_login’ );
    function my_redirect_to_login() {
    $pages = array( ‘member-homepage’, ‘calendar’ );
    if ( ! is_user_logged_in() && is_page( $pages ) ) {
    wpmem_redirect_to_login();
    }
    return;
    }

    • This reply was modified 8 years, 2 months ago by sharon135.
    • This reply was modified 8 years, 2 months ago by sharon135.
    Thread Starter sharon135

    (@sharon135)

    My apologies for not understanding your instructions and how some of shortcodes work, particularly log in and redirects and how the defaults work.

    I forgot to mention as part of the theme (Kadence Themes, Virtue Premium) I am using, they have “site origin editor” widgets I use via Page Builder. That’s where I had much of the content in layered site origin editor widgets for each page, even the blocked ones. Maybe that is part of the problem I am having hiding the content and the code you gave not working. Don’t know if I should put code inside each editor widget or not.

    I can see that a simple redirect to the log in page is best and easier, but the code you gave me doesn’t seem to do that. I continue to mess up somehow. I converted all blocked pages back to simple editor to see if the code will work there but don’t know where to put it. In Page Builder it gives me an attributes css field for each site origin editor. But not in visual/text editor. And when the code is put in each editor widget, it repeats the log in fields with no redirect to the log in page.

    Thank you for your patience with me on this. Having same issue on these blocked pages – Calendar, Documents, Builders, Links. At least the Member homepage hides content and has a log in field on the page instead of a redirect. I used this . . .[wpmem_form login redirect_to=”https://waterstone.celebratingyourjourney.com/member-homepage/”%5D content [/wpmem_form] to get Member Homepage to work that way.
    https://www.waterstone.celebratingyourjourney.com/

    • This reply was modified 8 years, 2 months ago by sharon135.
    Plugin Author Chad Butler

    (@cbutlerjr)

    Sorry – I may have made an assumption there. Code snippets like this need to go in the proper place. Generally, this means your theme’s functions.php file. Alternatively, a lot of people prefer to create a custom plugin file to store their custom code snippets.

    There’s a free article on my support site that discusses how to use code snippets that are discussed on the site – where to put them, how to read them, etc.

    https://rocketgeek.com/basics/using-code-snippets-from-the-site/

    There are some links in there to other core articles that are also freely available that discuss how to use the functions.php file or how to set up a custom plugin file. That’s what you need to do with that code snippet for it to be able to work.

    Thread Starter sharon135

    (@sharon135)

    I just realized that maybe I can make this easier all around and just make the logged in menu not visible until user is logged in. Right? That way no need for log in redirects, right?

    https://rocketgeek.com/tips-and-tricks/creating-menus-based-on-login-status/
    code to add to my theme…right? If so, which part of the code identifies the logged in menu?

    Here’s another option you give…
    https://rocketgeek.com/filter-hooks/creating-menus-based-on-login-status-alternate-version/

    Which way do you think is best? I currently have the logged in menu showing on top bar.
    https://www.waterstone.celebratingyourjourney.com

    Thread Starter sharon135

    (@sharon135)

    First, I think I can put it in the theme’s function.php. But my theme also has a “Advanced” styling css option in their theme option settings. So, I think I can put code there.

    But if I decide instead to go with creating menus based on login status, here’s the code you offer below to replace line in theme’s header.php file. You mention that a variable $menu is used to provide the menu name depending on the user’s login status. Does that mean I change $menu to my logged-in menu name? My logged in member menu name is “Member Pages” and is placed on topbar navigation. And the logged out menu name, “Main Menu” which is the primary and mobile navigation. Thanks for clarifying.

    <?php
    if( is_user_logged_in() ) {
    $menu = ‘logged-in’;
    } else {
    $menu = ‘logged-out’;
    }
    wp_nav_menu( array( ‘menu’ => $menu, ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘primary’ ) );
    ?>;

    • This reply was modified 8 years, 2 months ago by sharon135.
    Thread Starter sharon135

    (@sharon135)

    Forgot to mention that when users are logged in I want them to see both Member pages and Logged out pages.

    Plugin Author Chad Butler

    (@cbutlerjr)

    First, I think I can put it in the theme’s function.php. But my theme also has a “Advanced” styling css option in their theme option settings. So, I think I can put code there.

    That would allow you to add custom CSS styles/properties; but not PHP code.

    Thread Starter sharon135

    (@sharon135)

    https://www.waterstone.celebratingyourjourney.com

    Thanks. Could you clarify the use of the following code:
    “But if I decide instead to go with creating menus based on login status, here’s the code you offer below to replace line in theme’s header.php file. You mention that a variable $menu is used to provide the menu name depending on the user’s login status. Does that mean I change $menu to my logged-in menu name? My logged in member menu name is “Member Pages” and is placed on topbar navigation. And the logged out menu name, “Main Menu” which is the primary and mobile navigation. I assume logged in user will be able to see both logged in and logged out menus.”

    <?php
    if( is_user_logged_in() ) {
    $menu = ‘logged-in’;
    } else {
    $menu = ‘logged-out’;
    }
    wp_nav_menu( array( ‘menu’ => $menu, ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘primary’ ) );
    ?>;

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘restrict page content viewing for logged off/non-registered users’ is closed to new replies.