<?php /** * wpaam Template: Profile. * Displays the user profile. * * @package wp-user-manager * @copyright Copyright (c) 2015, Alessandro Tesoro * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * @since 1.0.0 */ // Display error message if no user has been found. if (!is_object($user_data)) { $args = array('id' => 'wpaam-profile-not-found', 'type' => 'error', 'text' => __('User not found.', 'wpaam')); wpaam_message($args); return; } do_action("wpaam_before_profile", $user_data); ?> <!-- start profile --> <div class="wpaam-single-profile" id="wpaam-profile-<?php echo $user_data->ID; ?> "> <?php do_action("wpaam_before_profile_details", $user_data); ?> <!-- Profile details wrapper -->
/** * Checks if profiles are available. * * @uses wpaam_is_single_profile * @uses wpaam_guests_can_view_profiles * @uses wpaam_members_can_view_profiles * @since 1.0.0 * @return bool */ function wpaam_can_access_profile() { $pass = true; // Check if not logged in and on profile page - no given user if (!is_user_logged_in() && !wpaam_is_single_profile()) { // Display error message $args = array('id' => 'wpaam-guests-disabled', 'type' => 'notice', 'text' => sprintf(__('This content is available to members only. Please <a href="%s">login</a> or <a href="%s">register</a> to view this area.', 'wpaam'), wpaam_get_core_page_url('login'), wpaam_get_core_page_url('register'))); wpaam_message($args); $pass = false; } // Block guests on single profile page if option disabled if (!is_user_logged_in() && wpaam_is_single_profile() && !wpaam_guests_can_view_profiles()) { // Display error message $args = array('id' => 'wpaam-guests-disabled', 'type' => 'notice', 'text' => sprintf(__('This content is available to members only. Please <a href="%s">login</a> or <a href="%s">register</a> to view this area.', 'wpaam'), wpaam_get_core_page_url('login'), wpaam_get_core_page_url('register'))); wpaam_message($args); $pass = false; } // Block members on single profile page if option disabled if (is_user_logged_in() && wpaam_is_single_profile() && !wpaam_members_can_view_profiles() && !wpaam_is_own_profile()) { // Display error message $args = array('id' => 'wpaam-no-access', 'type' => 'notice', 'text' => __('You are not authorized to access this area.', 'wpaam')); wpaam_message($args); $pass = false; } return apply_filters('wpaam_can_access_profile', $pass); }
function wpaam_profile_update_messages() { if (isset($_GET['updated']) && $_GET['updated'] == 'success') { $args = array('id' => 'wpaam-profile-updated', 'type' => 'success', 'text' => apply_filters('wpaam_account_update_success_message', __('Profile successfully updated.', 'wpaam'))); wpaam_message($args); } if (isset($_GET['updated']) && $_GET['updated'] == 'error') { $args = array('id' => 'wpaam-profile-error', 'type' => 'error', 'text' => apply_filters('wpaam_account_update_error_message', __('Something went wrong.', 'wpaam'))); wpaam_message($args); } }
/** * Output the form. * * @access public * @since 1.0.0 * @return void */ public static function output($atts = array()) { // Get fields self::get_registration_fields(); if (isset($_POST['submit_wpaam_register'])) { // Show errors from fields self::show_errors(); // Show confirmation messages self::show_confirmations(); } // Display template if (!get_option('users_can_register')) { // Display error message $message = array('id' => 'wpaam-registrations-disabled', 'type' => 'notice', 'text' => __('Registrations are currently disabled.', 'wpaam')); wpaam_message($message); } elseif (is_user_logged_in()) { get_wpaam_template('already-logged-in.php', array('args' => $atts)); // Show register form if not logged in } else { get_wpaam_template('forms/registration-form.php', array('atts' => $atts, 'form' => self::$form_name, 'register_fields' => self::get_fields('register'))); } }
<!-- start directory --> <div id="wpaam-user-directory-<?php echo $directory_args['directory_id']; ?> " class="wpaam-user-directory directory-<?php echo $directory_args['directory_id']; ?> "> <!-- Start Users list --> <?php do_action('wpaam_before_user_directory', $directory_args); if (!empty($directory_args['user_data'])) { echo '<ul class="wpaam-user-listings">'; foreach ($directory_args['user_data'] as $user) { // Load single-user.php template to display each user individually get_wpaam_template("directory/single-user.php", array('user' => $user)); } echo "</ul>"; } else { $args = array('id' => 'wpaam-no-user-found', 'type' => 'notice', 'text' => __('No users have been found', 'wpaam')); $warning = wpaam_message($args, true); } do_action('wpaam_after_user_directory', $directory_args); ?> <!-- end users list --> </div> <!-- end directory -->