Support » Plugin: WP-Members Membership Plugin » All content appears to be blocked or not visible on login

  • Resolved DebsWebs

    (@debswebs)


    Hi Chad,

    I have been using the WP-Members and WP-Member Advanced Options successfully for over a year. However, suddenly today (at least I discovered it today) when a user logs in, the entire site’s content (except for the menu) disappears. You can click on the menu items and it takes you to the correct page, but all pages are blank. I removed all of the plugins on the site and added them back one at a time and discovered that the problem occurred when I added the WP-Members back in and activated it.

    I am having trouble figuring anything out because not only is the page content “gone” but so are all the links to the admin section. It’s basically just a blank page with the logo and the menu. Nothing else is visible.

    Here is a link to my site: http://www.thebriarglen.com
    I would appreciate any help you can provide.
    I am running version 3.2.2.1 on WordPress 4.9.8
    Thanks in advance for any ideas on how to fix this problem.

    The page I need help with: [log in to see the link]

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

    (@cbutlerjr)

    What version of WP-Members Advanced Options that is installed?

    It is 2.0.0

    Hi Chad,

    I’m wondering if you have had a chance to look at this issue any more. It seems that it might be related to the update of WordPress 4.9.8.

    Plugin Author Chad Butler

    (@cbutlerjr)

    Hi Deb,

    Sorry – I’ve not been able to get to the wordpress.org forum as much. Even if your support subscription is not current, you can still contact me via the rocketgeek.com/contact form and we’ll get this looked at in a more timely manner. Since you’ve got the most recent versions of the extension and the plugin, I’m probably going to have to look at this directly.

    • This reply was modified 2 years, 5 months ago by Chad Butler.

    OK. I will switch over to the rocketgeek.com/contact form for my next communication.

    Hi Chad,

    I tried to contact you via the rocketgeek contact form, but I got a message that said my message failed to send and that I should contact the administrator via another method. So I am back here.

    Here is the message that I am trying to send via rocketgeek.

    Hi Chad,
    We had been communicating at the WordPress.org forum about this issue.

    I have a bit more information concerning the issue. I am using a child theme and in the functions.php file for the child theme, I have this additional code.

    add_action( ‘template_redirect’, ‘my_redirect_to_login’ );
    function my_redirect_to_login() {
    if ( ! is_user_logged_in() && wpmem_current_url() == site_url( ‘/activity/’ ) ) {
    wpmem_redirect_to_login();
    } elseif
    ( ! is_user_logged_in() && wpmem_current_url() == site_url( ‘/members/’ ) ) {
    wpmem_redirect_to_login();
    }
    return;
    }

    /**
    * A simple function to create a settings array
    * for access levels and information.
    */
    function my_post_access_levels() {
    return array(
    ‘levels’ => array(
    /**
    * Set array values as:
    * metavalue => label,
    */
    ‘renter’ => ‘Renter/Tenant’,
    ‘owner’ => ‘Owner’,
    ‘board’ => ‘Board’,
    ),
    ‘default’ => ‘renter’,
    ‘user_field’ => ‘user_level’,
    ‘post_field’ => ‘post_access’,
    ‘error_msg’ => ‘Your account does not have access to this page.’
    );
    }

    // No need to change anything after this line.

    /**
    * Set the user to the default at registration.
    */
    add_action( ‘wpmem_post_register_data’, ‘set_default_level’ );
    function set_default_level( $fields ){
    extract( my_post_access_levels() );
    update_user_meta( $fields[‘ID’], $user_field, $default );
    }
    /**
    Allows new user registration to go to an email in addition to the general settings admin email.
    */
    add_filter( ‘wpmem_notify_addr’, ‘my_admin_email’ );

    function my_admin_email( $email ) {

    // take the default and append a second address to it example:
    $email = $email . ‘, johnf@moarefims.com’;

    // return the result
    return $email;
    }

    /**
    * Sets up access restriction by User ID and access level
    */
    add_filter( ‘wpmem_securify’, ‘check_user_access’ );
    function check_user_access( $content ) {

    // Is the content to be blocked and is the user logged in?
    if ( is_user_logged_in() && wpmem_block() == true ) {

    // Get settings.
    extract( my_post_access_levels() );

    // We need the user’s ID and the $post object.
    global $user_ID, $post;

    // Get the user’s access level.
    $user_level = get_user_meta( $user_ID, $user_field, true );

    // Get the post access level.
    $post_access = get_post_meta( $post->ID, $post_field, true );

    // Evaluate level hierarchy.
    $i = array_search( $post_access, array_keys( $levels ) );
    $x = array_search( $user_level, array_keys( $levels ) );

    // If the user level is less than post level, return
    // error message. otherwise return $content.
    return ( $x < $i ) ? $error_msg : $content;
    }

    // Return unfiltered content for all other cases.
    return $content;
    }

    /** Admin panel elements */

    /**
    * Add dropdown to post and page meta box for marking level.
    */
    add_action( ‘wpmem_admin_after_block_meta’, ‘my_add_post_level’, 10, 2 );
    function my_add_post_level( $post, $block ) {

    // Get the settings.
    extract( my_post_access_levels() );

    // Get the current access setting, if any.
    $post_access = get_post_meta( $post->ID, $post_field, true );

    // Create dropdown selector of users for access.
    echo ‘<label>Limit access to: </label>
    <select name=”post_access”>
    <option value=””>Select User Level</option>’;
    foreach ( $levels as $meta => $label ) {
    $selected = ( $meta == $post_access ) ? ‘selected’ : ”;
    echo “<option value=\”$meta\” $selected>$label</option>;”;
    }
    echo ‘</select>’;
    }

    /**
    * Save custom post meta for user ID access.
    */
    add_action(‘wpmem_admin_block_meta_save’,’my_add_post_level_save’,10,3);
    function my_add_post_level_save( $post, $block, $unblock ) {

    extract( my_post_access_levels() );
    if ( isset( $_POST[$post_field] ) ) {
    // If a user ID is passed to limit access, save it.
    update_post_meta( $post->ID, $post_field, $_POST[$post_field] );
    } else {
    // If no user ID is passed to limit access, delete any meta.
    delete_post_meta( $post->ID, $post_field );
    }
    }

    /*———– remove menu items based on user level ——————*/
    add_filter( ‘wp_get_nav_menu_items’, ‘my_remove_menu_item_by_level’, null, 3 );
    function my_remove_menu_item_by_level( $items, $menu, $args ) {
    // Get post level settings.
    extract( my_post_access_levels() );

    // Iterate through menu items and evaluate.
    foreach ( $items as $key => $item ) {
    // Get the post access level.
    $post_access = get_post_meta( $item->object_id, $post_field, true );
    // If the user is logged in, check user level.
    if ( is_user_logged_in() ) {
    // Get the user’s access level.
    $user_level = get_user_meta( get_current_user_id(), $user_field, true );
    // Evaluate level hierarchy.
    $i = array_search( $post_access, array_keys( $levels ) );
    $x = array_search( $user_level, array_keys( $levels ) );
    // If user level is too low, remove the item.
    if ( $x < $i ) {
    unset( $items[ $key ] );
    }
    } else {
    // User is not logged in, if the post has a level, remove it.
    if ( $post_access ) {
    unset( $items[ $key ] );
    }
    }
    }
    return $items;
    }
    add_action( ‘pre_get_posts’, ‘my_query_exclusions’ );
    function my_query_exclusions( $query ) {
    if( $query->is_search && ! is_user_logged_in() ) {
    $meta_query = array(
    array(
    ‘key’=>’_wpmem_block’,
    ‘value’=>’0’,
    ‘compare’=>’=’,
    ),
    );
    $query->set(‘meta_query’,$meta_query);
    }
    return $query;
    }
    ?>

    I am having to disable this because now my website will not even load. It just presents a blank white page. So, in order to get the site functional again (without the membership stuff), I need to remove this section of code from the child theme.

    Please advise how I should proceed. This site has been functioning without any problems for well over a year until the latest WordPress update.
    Thanks in advance for your help. By the way, I am going to be needing to create another site in the next few weeks that will also need the Membership plugins so I am really worried about getting this fixed and then properly set up on the new site as well.

    Debbie

    Hi Chad,
    I have another update for you. I downgraded my WordPress installation to 4.9.7 and then activated the WP Members plugin (but not the WP-Members Advanced Options plugin) and the site reverted back to just the background colors. So, maybe it’s not the update of the WordPress installation that caused the problem.

    So, now I am clueless as to what might be wrong. The site was working perfectly until a few days ago. I haven’t done anything or even logged in to it in several weeks. It just suddenly stopped working as far as I can tell.

    Debbie

    Plugin Author Chad Butler

    (@cbutlerjr)

    The problem turned out to be two-fold. First, when updating, some of the custom code used in the functions.php file used a deprecated function that was removed in plugin version 3.2 – wpmem_block().

    Also, because the code used a WP-Members function that was called in a custom function hooked to a WP hook, when the plugin was deactivated, that function did not exist and threw an error as a result. Wrapping that with the check function_exists() resolves it.

    I marked this mod-look for the moderator to review the extremely large string of unformatted code in this thread – it should probably be redacted.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘All content appears to be blocked or not visible on login’ is closed to new replies.