function plugin_template_redirect() { if (rp_is_home()) { if (is_user_logged_in()) { if ($user_favorite_link = get_user_meta(get_current_user_id(), 'favorite_link', true)) { redirect_is_this_page_uri($user_favorite_link); } else { redirect_is_user_logged_in(); } } else { header("Location: " . get_option('redirect_link_guest')); } } }
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)); } } }