function redirect_from_main_page()
{
    if (is_front_page()) {
        $user_id = get_current_user_id();
        $person_id = get_person_by_user($user_id);
        $person_url = get_permalink($person_id);
        exit(wp_redirect($person_url));
    }
}
    function add_case_items_deadline()
    {
        $user_id = get_current_user_id();
        $person_id = get_person_by_user($user_id);
        ?>
    <li><a href="/cases?open=yes&deadline=yes&meta_responsible-cp-posts-sql=<?php 
        echo $person_id;
        ?>
">Срочные</a></li>
    <li><a href="/cases?open=yes&deadline=fail&meta_responsible-cp-posts-sql=<?php 
        echo $person_id;
        ?>
">Нарушен срок</a></li>
	<?php 
    }
Beispiel #3
0
function sc_get_meta_cp($atts)
{
    extract(shortcode_atts(array('object' => 'post', 'meta' => 'no', 'key' => 'id', 'id' => 'current'), $atts));
    switch ($object) {
        case 'post':
            //Вычисляем $post_id
            switch ($id) {
                case 'current':
                    $post = get_post();
                    $post_id = $post->ID;
                    break;
                case 'current_person':
                    $user_id = get_current_user_id();
                    $post_id = get_person_by_user($user_id);
                    break;
                default:
                    $post_id = $id;
                    $post = get_post($post_id);
                    break;
            }
            if ($meta == 'yes') {
                $value = get_post_meta($post_id, $key, true);
            } else {
                $value = $post->{$key};
            }
            break;
        case 'user':
            //Вычисляем $user_id
            switch ($id) {
                case 'current':
                    $user_id = get_current_user_id();
                    break;
                default:
                    $user_id = $id;
                    break;
            }
            $user = get_user_by('id', $user_id);
            if ($meta == 'yes') {
                $value = get_user_meta($user_id, $key, true);
            } else {
                $value = $user->{$key};
            }
            break;
    }
    $html = $value;
    return $html;
}
Beispiel #4
0
function add_case_items_navigation()
{
    $user_id = get_current_user_id();
    $person_id = get_person_by_user($user_id);
    ?>
    <li id="my_cases"><strong>Мои дела</strong>
        <ul>
			<li><a href="/cases?open=yes&meta_responsible-cp-posts-sql=<?php 
    echo $person_id;
    ?>
">Ответственный</a></li>
			<li><a href="/cases?open=yes&meta_members-cp-posts-sql=<?php 
    echo $person_id;
    ?>
">Участник</a></li>
        </ul>
    </li>
	<?php 
}
Beispiel #5
0
function redirect_is_user_logged_in()
{
    $option = '';
    if (get_option('redirect_type') == 'post') {
        $option = get_permalink(get_option('redirect_posts_list'));
        redirect_is_this_page_uri($option);
    }
    if (get_option('redirect_type') == 'link') {
        $option = get_permalink(get_option('redirect_links_list'));
        redirect_is_this_page_uri($option);
    }
    if (get_option('redirect_type') == 'custom_url') {
        $option = get_option('redirect_link_user');
        redirect_is_this_page_uri($option);
    }
    if (get_option('redirect_type') == 'category') {
        $term = get_term_by('id', get_option('redirect_category'), 'category');
        $option = get_term_link($term);
        redirect_is_this_page_uri($option);
    }
    if (get_option('redirect_type') == 'person') {
        $current_person = get_person_by_user(wp_get_current_user()->ID);
        if ($current_person && ($personName = get_post($current_person)->post_name)) {
            redirect_is_this_page_uri(home_url('/?persons=' . $personName));
        }
    }
}