public static function get_logged_in_members_level() { $auth = BAuth::get_instance(); if (!$auth->is_logged_in()) { return bUtils::_("User is not logged in."); } return $auth->get('membership_level'); }
public function edit() { global $wpdb; $auth = BAuth::get_instance(); if (!$auth->is_logged_in()) { return; } $user_data = (array) $auth->userData; unset($user_data['permitted']); $form = new BForm($user_data); if ($form->is_valid()) { global $wpdb; $member_info = $form->get_sanitized(); // update corresponding wp user. BUtils::update_wp_user($auth->get('user_name'), $member_info); if (isset($member_info['plain_password'])) { unset($member_info['plain_password']); } $wpdb->update($wpdb->prefix . "swpm_members_tbl", $member_info, array('member_id' => $auth->get('member_id'))); $auth->reload_user_data(); $message = array('succeeded' => true, 'message' => 'Profile Updated.'); BTransfer::get_instance()->set('status', $message); } else { $message = array('succeeded' => false, 'message' => BUtils::_('Please correct the following'), 'extra' => $form->get_errors()); BTransfer::get_instance()->set('status', $message); return; } }
public function filter_post($id, $content) { if (in_array($id, $this->moretags)) { return $content; } if ($this->can_i_read_post($id)) { return $content; } $moretag = BSettings::get_instance()->get_value('enable-moretag'); if (empty($moretag)) { return $this->lastError; } $post = get_post($id); $post_segments = explode('<!--more-->', $post->post_content); if (count($post_segments) >= 2) { if (BAuth::get_instance()->is_logged_in()) { $error_msg = '<div class="swpm-margin-top-10">' . BUtils::_(" The rest of the content is not permitted for your membership level.") . '</div>'; $this->lastError = apply_filters('swpm_restricted_more_tag_msg', $error_msg); } else { $error_msg = '<div class="swpm-margin-top-10">' . BUtils::_("You need to login to view the rest of the content. ") . BSettings::get_instance()->get_login_link() . '</div>'; $this->lastError = apply_filters('swpm_not_logged_in_more_tag_msg', $error_msg); } return do_shortcode($post_segments[0]) . $this->lastError; } return $this->lastError; }