예제 #1
0
파일: filters.php 프로젝트: devd123/wpaam
/**
 * Adjust the output of the first name/last name field to display a full name if the option is enabled.
 * If the option is enabled into the first name field, wpaam will display the first name + last name,
 * if the option is enabled into the last name field, wpaam will display the last name + first name.
 *
 * @param  string $value the value of field.
 * @param  string $field  field object.
 * @return string        output of this field.
 * @since 1.2.0
 */
function wpaam_adjust_name_meta_output($value, $field)
{
    if (wpaam_is_single_profile()) {
        if ($field->meta == 'first_name' && wpaam_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpaam_get_user_lname(wpaam_get_displayed_user_id());
        } elseif ($field->meta == 'last_name' && wpaam_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpaam_get_user_fname(wpaam_get_displayed_user_id());
        }
    }
    return $value;
}
예제 #2
0
파일: actions.php 프로젝트: devd123/wpaam
/**
 * Force 404 error if user or tabs do not exist.
 *
 * @since 1.0.0
 * @access public
 * @return void
 */
function wpaam_profile_force_404_error()
{
    // Bail if not on the profile page
    if (!is_page(wpaam_get_core_page_id('profile'))) {
        return;
    }
    // Bail if viewing single profile only and not another user profile
    if (!wpaam_is_single_profile()) {
        return;
    }
    // Trigger if tab is set and does not exist
    if (wpaam_get_current_profile_tab() !== null && !wpaam_profile_tab_exists(wpaam_get_current_profile_tab())) {
        wpaam_trigger_404();
    }
    // Trigger if profile is set and does not exist
    if (wpaam_is_single_profile() && !wpaam_user_exists(wpaam_is_single_profile(), get_option('wpaam_permalink'))) {
        wpaam_trigger_404();
    }
}
예제 #3
0
파일: functions.php 프로젝트: devd123/wpaam
/**
 * 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);
}
예제 #4
0
파일: filters.php 프로젝트: devd123/wpaam
/**
 * Add custom classes to body tag
 *
 * @since       1.0.0
 * @param       array $classes
 * @return      array
 */
function wpaam_body_classes($classes)
{
    if (is_page(wpaam_get_core_page_id('login'))) {
        // add class if we're on a login page
        $classes[] = 'wpaam-login-page';
    } else {
        if (is_page(wpaam_get_core_page_id('register'))) {
            // add class if we're on a register page
            $classes[] = 'wpaam-register-page';
        } else {
            if (is_page(wpaam_get_core_page_id('account'))) {
                // add class if we're on a account page
                $classes[] = 'wpaam-account-page';
            } else {
                if (is_page(wpaam_get_core_page_id('profile'))) {
                    // add class if we're on a profile page
                    $classes[] = 'wpaam-profile-page';
                    // add user to body class if set
                    if (wpaam_is_single_profile()) {
                        $classes[] = 'wpaam-user-' . wpaam_is_single_profile();
                    }
                } else {
                    if (is_page(wpaam_get_core_page_id('password'))) {
                        // add class if we're on a password page
                        $classes[] = 'wpaam-password-page';
                    }
                }
            }
        }
    }
    return $classes;
}
예제 #5
0
파일: functions.php 프로젝트: devd123/wpaam
function wpaam_get_displayed_user_id()
{
    $user_id = false;
    $who = wpaam_is_single_profile();
    $structure = get_option('wpaam_permalink', 'user_id');
    // If we're on the profile but no user has been given, we return the current user id.
    if (!$who && !empty($structure) && is_page(wpaam_get_core_page_id('profile'))) {
        return get_current_user_id();
    }
    // Process the retrieved user.
    if ($who && !empty($structure)) {
        switch ($structure) {
            case 'user_id':
                $user_id = esc_attr($who);
                break;
            case 'username':
                $retrieve = get_user_by('login', esc_attr($who));
                $user_id = $retrieve->data->ID;
                break;
            case 'nickname':
                // WP_User_Query arguments.
                $args = array('search' => esc_attr($who), 'search_columns' => array('user_nicename'));
                // The User Query.
                $user_query = new WP_User_Query($args);
                $user_query = $user_query->get_results();
                $user_id = $user_query[0]->data->ID;
                break;
        }
    }
    return $user_id;
}