Example #1
0
function ihc_register_form($attr = false)
{
    $str = '';
    $user_type = ihc_get_user_type();
    if ($user_type == 'unreg') {
        ///////ONLY UNREGISTERED CAN SEE THE REGISTER FORM
        if (isset($_GET['ihc_register'])) {
            return;
        }
        $template = get_option('ihc_register_template');
        $str .= '<style>' . get_option('ihc_register_custom_css') . '</style>';
        include_once IHC_PATH . 'classes/UserAddEdit.class.php';
        $args = array('user_id' => false, 'type' => 'create', 'tos' => true, 'captcha' => true, 'action' => '', 'is_public' => true, 'register_template' => $template);
        $obj_form = new UserAddEdit();
        $obj_form->setVariable($args);
        //setting the object variables
        $str .= '<div class="iump-register-form ' . $template . '">' . $obj_form->form() . '</div>';
        //print the Errors
        global $ihc_error_register;
        if (!empty($ihc_error_register)) {
            $str .= '<div class="ihc-wrapp-the-errors">' . $ihc_error_register . '</div>';
        }
    }
    return $str;
}
Example #2
0
    return $str;
}
//////////LIST POSTS - FILTER REMOVE POSTS THAT HAS A REDIRECT BLOCK
add_filter('pre_get_posts', 'ihc_filter_query_list_posts', 999);
function ihc_filter_query_list_posts($query)
{
    if (!$query->is_single && !$query->is_page) {
        $current_user = ihc_get_user_type();
        if ($current_user == 'admin') {
            return $query;
        }
        //show all to admin
        ///
        global $wpdb;
        $post_list = $wpdb->get_results('SELECT DISTINCT post_id
											FROM ' . $wpdb->prefix . 'postmeta
											WHERE meta_key = "ihc_mb_block_type"
											AND meta_value = "redirect"
										;');
        if ($post_list && count($post_list)) {
            $exclude = array();
            foreach ($post_list as $obj) {
                if (isset($obj->post_id) && $obj->post_id) {
                    $result = $wpdb->get_results('
														SELECT * FROM ' . $wpdb->prefix . 'postmeta
														WHERE post_id = ' . $obj->post_id . '
														AND ( meta_key = "ihc_mb_type"
														OR meta_key = "ihc_mb_who") LIMIT 2
												;');
                    $for = false;
                    $type = false;
                    foreach ($result as $obj2) {
                        ///
                        if ($obj2->meta_key == 'ihc_mb_who') {
                            $for = $obj2->meta_value;
                        } elseif ($obj2->meta_key == 'ihc_mb_type') {
                            $type = $obj2->meta_value;
                        }
                    }
                    if ($for && $type) {
                        $for = explode(',', $for);
                        $block = ihc_test_if_must_block($type, $current_user, $for);
                        if ($block) {
                            $exclude[] = $obj->post_id;
Example #3
0
                $subscription_link = get_permalink($subscription_pid);
                if ($subscription_link) {
                    wp_redirect($subscription_link);
                    exit;
                }
            }
        }
    }
}
function ihc_block_page_content($postid, $url)
{
    /*  
	 * test if current post, page content must to blocked
	 */
    $meta_arr = ihc_post_metas($postid);
    if (isset($meta_arr['ihc_mb_block_type']) && $meta_arr['ihc_mb_block_type']) {
        if ($meta_arr['ihc_mb_block_type'] == 'redirect') {
            /////////////////////// REDIRECT
            if (isset($meta_arr['ihc_mb_who'])) {
                //getting current user type and target user types
                $current_user = ihc_get_user_type();
                if ($meta_arr['ihc_mb_who'] == -1) {
                    $meta_arr['ihc_mb_who'] = '';
                }
                //-1 means no value selected
                $target_users = explode(',', $meta_arr['ihc_mb_who']);
                //test if current user must be redirect
                if ($current_user == 'admin') {
                    return;
                }
                //show always for admin
                $redirect = ihc_test_if_must_block($meta_arr['ihc_mb_type'], $current_user, $target_users);
                if ($redirect) {
                    //getting default redirect id
                    $default_redirect_id = get_option('ihc_general_redirect_default_page');
                    //PREVENT INFINITE REDIRECT LOOP - if current page is default redirect page return
                    if ($default_redirect_id == $postid) {
                        return;
                    }
                    if (isset($meta_arr['ihc_mb_redirect_to']) && $meta_arr['ihc_mb_redirect_to'] != -1) {
                        $redirect_id = $meta_arr['ihc_mb_redirect_to'];
                        //redirect to value that was selected in meta box
                        //test if redirect page exists
                        if (get_post_status($redirect_id)) {
                            $redirect_link = get_permalink($redirect_id);
                        } else {
                            //if not exists go to homepage
                            $redirect_link = home_url();
                        }
                    } else {
                        if ($default_redirect_id && $default_redirect_id != -1) {
                            if (get_post_status($default_redirect_id)) {
                                $redirect_link = get_permalink($default_redirect_id);
                                //default redirect page, selected in general settings
                            } else {
                                $redirect_link = home_url();
                            }
                        } else {
                            $redirect_link = home_url();
                            //if default redirect page is not set, redirect to home
                        }
                    }
                    if ($url == $redirect_link) {
                        return;
                    }