Home Forums Responsive Themes Dating Theme expired memberships Reply To: expired memberships

  • JamesD
    Super Guru 1,714 points
    March 22, 2019 at 8:43 am

    Even better news… here’s a tweaked version that displays the proper message depending if the user has an active membership or normal login error message. There are a variety of ways to do this, but I believe this is more what you’re looking for.
    Note: This will display the Restricted Access Text message set under Theme Setup > Listing Setup > Membershp Packages > Extra Settings > Restricted Access Text. You should be able to use HTML in that setting as well. You may not even need the page-login.php file.

    I’ve attached an updated file with the code changes or you can copy/paste below and replace the previous code in the _functions.pnp file.
    * Restrict login if no active membership
    * Fired by authenticate action hook.
    * @access public
    * @param WP_Object $user
    * @param string $username
    * @param string $password
    * @return object (either WP_Object or WP_Error)
    add_filter( 'authenticate', 'check_active_account', 30, 3);
    function check_active_account($user, $username, $password) {
    global $GLOBALS;

    // Checks for the first user record (admin)
    if( 1 === $user->ID ) { return $user; }

    // Checks if user has a membership
    $membershp = get_user_meta($user->ID, 'wlt_membership',true);

    // Checks for expired membership date
    $expires = get_user_meta($user->ID, 'wlt_membership_expires',true);

    // Checks if user has a valid or expired membership
    $not_active = ( strtotime($expires) <= strtotime(date("Y-m-d H:i:s")) )?true:false;

    // Set message depending if normal login message or custom message when no membership or expired.
    $msg = (is_wp_error( $user ))?$user->get_error_message():stripslashes($GLOBALS['CORE_THEME']['membership_restrictedtext']);

    // If user does not have an active membership we display the error message, otherwise pass the user object back for valid login
    return (true === $not_active)?new WP_Error( 'broke', $msg ):$user;

    You must be logged in to view attached files.
  • New Business Themes for WordPress 2020

    Start your new website today!

    View Business Themes