function userpro_logout_page()
{
    global $userpro;
    if (is_page() || is_single()) {
        global $post;
        $pages = get_option('userpro_pages');
        if ($post->ID == $pages['logout_page']) {
            if (userpro_is_logged_in()) {
                $logout = userpro_get_option('logout_uri');
                if ($logout == 1) {
                    $url = home_url();
                }
                if ($logout == 2) {
                    $url = $userpro->permalink(0, 'login');
                }
                if ($logout == 3) {
                    $url = userpro_get_option('logout_uri_custom');
                }
                if (isset($_REQUEST['redirect_to'])) {
                    $url = $_REQUEST['redirect_to'];
                }
                wp_logout();
                wp_redirect($url);
                exit;
            } else {
                wp_redirect($userpro->permalink(0, 'login'));
                exit;
            }
        }
    }
}
Пример #2
0
function userpro_sc_show_follow($user_id)
{
    global $userpro, $userpro_social;
    if (!userpro_get_option('modstate_social')) {
        return false;
    }
    if (userpro_is_logged_in() && !$userpro->is_user_logged_user($user_id)) {
        echo '<div class="userpro-sc-flw">' . $userpro_social->follow_text($user_id, get_current_user_id()) . '</div>';
    }
}
Пример #3
0
function userpro_loggedout($args = array(), $content = null)
{
    global $wp, $userpro_admin, $userpro;
    ob_start();
    if (!userpro_is_logged_in()) {
        echo do_shortcode($content);
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Пример #4
0
function userpro_allow_profile_redirect()
{
    global $userpro;
    if (userpro_get_option('allow_dashboard_for_these_roles') && userpro_is_logged_in() && $userpro->user_role_in_array(get_current_user_id(), explode(',', userpro_get_option('allow_dashboard_for_these_roles')))) {
        return false;
    }
    if (!current_user_can('manage_options') && userpro_get_option('profile_redirect_users')) {
        return true;
    }
    return false;
}
Пример #5
0
function userpro($args = array())
{
    global $post, $wp, $userpro_admin, $userpro;
    if (is_home()) {
        $permalink = home_url();
    } else {
        if (isset($post->ID)) {
            $permalink = get_permalink($post->ID);
        } else {
            $permalink = '';
        }
    }
    /* arguments */
    $defaults = apply_filters('userpro_shortcode_args', array('template' => null, 'max_width' => userpro_get_option('width'), 'uploads_dir' => $userpro->get_uploads_url(), 'default_avatar_male' => userpro_url . 'img/default_avatar_male.jpg', 'default_avatar_female' => userpro_url . 'img/default_avatar_female.jpg', 'layout' => userpro_get_option('layout'), 'margin_top' => 0, 'margin_bottom' => '30px', 'align' => 'center', 'skin' => userpro_get_option('skin'), 'required_text' => __('This field is required', 'userpro'), 'password_too_short' => __('Your password is too short', 'userpro'), 'passwords_do_not_match' => __('Passwords do not match', 'userpro'), 'password_not_strong' => __('Password is not strong enough', 'userpro'), 'keep_one_section_open' => 1, 'allow_sections' => 1, 'permalink' => $permalink, 'field_icons' => userpro_get_option('field_icons'), 'profile_thumb_size' => 80, 'register_heading' => __('Register an Account', 'userpro'), 'register_side' => __('Already a member?', 'userpro'), 'register_side_action' => 'login', 'register_button_action' => 'login', 'register_button_primary' => __('Register', 'userpro'), 'register_button_secondary' => __('Login', 'userpro'), 'register_group' => 'default', 'register_redirect' => '', 'type' => userpro_mu_get_option('multi_forms_default'), 'login_heading' => __('Login', 'userpro'), 'login_side' => __('Forgot your password?', 'userpro'), 'login_side_action' => 'reset', 'login_button_action' => 'register', 'login_button_primary' => __('Login', 'userpro'), 'login_button_secondary' => __('Create an Account', 'userpro'), 'login_group' => 'default', 'login_redirect' => '', 'delete_heading' => __('Delete Profile', 'userpro'), 'delete_side' => __('Undo, back to profile', 'userpro'), 'delete_side_action' => 'view', 'delete_button_action' => 'view', 'delete_button_primary' => __('Confirm Deletion', 'userpro'), 'delete_button_secondary' => __('Back to Profile', 'userpro'), 'delete_group' => 'default', 'reset_heading' => __('Reset Password', 'userpro'), 'reset_side' => __('Back to Login', 'userpro'), 'reset_side_action' => 'login', 'reset_button_action' => 'change', 'reset_button_primary' => __('Request Secret Key', 'userpro'), 'reset_button_secondary' => __('Change your Password', 'userpro'), 'reset_group' => 'default', 'change_heading' => __('Change your Password', 'userpro'), 'change_side' => __('Request New Key', 'userpro'), 'change_side_action' => 'reset', 'change_button_action' => 'reset', 'change_button_primary' => __('Change my Password', 'userpro'), 'change_button_secondary' => __('Do not have a secret key?', 'userpro'), 'change_group' => 'default', 'list_heading' => __('Latest Members', 'userpro'), 'list_per_page' => 5, 'list_sortby' => 'registered', 'list_order' => 'desc', 'list_users' => '', 'list_group' => 'default', 'list_thumb' => 50, 'list_showthumb' => 1, 'list_showsocial' => 1, 'list_showbio' => 0, 'list_verified' => 0, 'list_relation' => 'or', 'online_heading' => __('Who is online now', 'userpro'), 'online_thumb' => 30, 'online_showthumb' => 1, 'online_showsocial' => 0, 'online_showbio' => 0, 'online_mini' => 1, 'online_mode' => 'vertical', 'edit_button_primary' => __('Save Changes', 'userpro'), 'edit_group' => 'default', 'view_group' => 'default', 'social_target' => '_blank', 'social_group' => 'default', 'card_width' => '250px', 'card_img_width' => '250', 'card_showbio' => 1, 'card_showsocial' => 1, 'link_target' => '_blank', 'error_heading' => __('An error has occured', 'userpro'), 'memberlist_v2' => 1, 'memberlist_v2_pic_size' => '86', 'memberlist_v2_fields' => 'age,gender,country', 'memberlist_v2_bio' => 1, 'memberlist_v2_showbadges' => 1, 'memberlist_v2_showname' => 1, 'memberlist_v2_showsocial' => 1, 'memberlist_pic_size' => '120', 'memberlist_pic_topspace' => '15', 'memberlist_pic_sidespace' => '30', 'memberlist_pic_rounded' => 1, 'memberlist_width' => '100%', 'memberlist_paginate' => 1, 'memberlist_paginate_top' => 1, 'memberlist_paginate_bottom' => 1, 'memberlist_show_name' => 1, 'memberlist_popup_view' => 0, 'memberlist_withavatar' => 0, 'memberlist_verified' => 0, 'memberlist_filters' => '', 'memberlist_default_search' => 1, 'per_page' => 12, 'sortby' => 'registered', 'order' => 'desc', 'relation' => 'and', 'search' => 1, 'show_social' => 1, 'registration_closed_side' => __('Existing member? login', 'userpro'), 'registration_closed_side_action' => 'login', 'facebook_redirect' => 'profile', 'logout_redirect' => '', 'postsbyuser_num' => '12', 'postsbyuser_types' => 'post', 'postsbyuser_mode' => 'grid', 'postsbyuser_thumb' => 50, 'postsbyuser_showthumb' => 1, 'publish_heading' => __('Add a New Post', 'userpro'), 'publish_button_primary' => __('Publish', 'userpro')));
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if ($template) {
        static $i = 0;
        ob_start();
        /* increment wall */
        $i = rand(1, 1000);
        /* user template */
        do_action('userpro_custom_template_hook', array_merge($args, array('i' => $i)));
        switch ($template) {
            case 'publish':
                if (userpro_is_logged_in()) {
                    $user_id = get_current_user_id();
                    $layout = 'none';
                    $args['layout'] = 'none';
                    if (isset($args['deny_roles']) && !empty($args['deny_roles'])) {
                        $denied_roles = explode(',', $args['deny_roles']);
                        if ($userpro->user_role_in_array($user_id, $denied_roles)) {
                            if (locate_template('userpro/not_allowed.php') != '') {
                                include get_template_directory() . '/userpro/not_allowed.php';
                            } else {
                                include userpro_path . "templates/not_allowed.php";
                            }
                        } else {
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_template_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                    } else {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    add_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                    remove_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                }
                break;
            case 'postsbyuser':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                $post_query = $userpro->posts_by_user($user_id, $args);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                wp_reset_query();
                break;
            case 'online':
                $users = $userpro->onlineusers();
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'request_verify':
                $userpro->new_verification_request($_POST['up_username']);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'reset':
                add_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                remove_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                break;
            case 'change':
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'delete':
                if (isset($args['user'])) {
                    $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ((int) $user_id) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'memberlist':
                $users = userpro_memberlist_loop($args);
                if ($args['memberlist_v2'] == 0) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (locate_template('userpro/' . $template . '_v2.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '_v2.php';
                    } else {
                        include userpro_path . "templates/{$template}" . "_v2.php";
                    }
                }
                break;
            case 'list':
                $users = userpro_memberlist_listusers($args, $list_users);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'card':
                if (isset($args['user'])) {
                    $try = get_user_by('login', $args['user']);
                    $user_id = $try->ID;
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    }
                } else {
                    if (userpro_is_logged_in()) {
                        $user_id = get_current_user_id();
                    }
                }
                if ($user_id) {
                    $get_user = get_userdata($user_id);
                    $user = $get_user->user_login;
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
            case 'register':
                if (userpro_get_option('users_can_register') == 0) {
                    $template = 'registration_closed';
                    $args['template'] = 'registration_closed';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_register')) {
                        if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_template_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                    } else {
                        $user_id = get_current_user_id();
                        if (locate_template('userpro/logout.php') != '') {
                            include get_template_directory() . '/userpro/logout.php';
                        } else {
                            include userpro_path . "templates/logout.php";
                        }
                    }
                }
                break;
            case 'login':
                if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_login')) {
                    if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    $user_id = get_current_user_id();
                    if (locate_template('userpro/logout.php') != '') {
                        include get_template_directory() . '/userpro/logout.php';
                    } else {
                        include userpro_path . "templates/logout.php";
                    }
                }
                break;
            case 'edit':
                if (userpro_get_edit_user()) {
                    $user_id = userpro_get_edit_user();
                    if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                        if (locate_template('userpro/' . $user_id . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $user_id . '.php';
                        } else {
                            include userpro_path . "templates/{$user_id}.php";
                        }
                    } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'view':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ($user_id == 'login_to_view') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif ($user_id == 'login_to_view_others') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
        }
        /**
        		START THEMING
        		**/
        if (in_array($align, array('left', 'right'))) {
            echo '<div class="userpro-clear"></div>';
        }
        if (class_exists('userpro_sk_api') && is_dir(userpro_sk_path . 'skins/' . $skin)) {
            wp_register_style('userpro_skin_min', userpro_sk_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        } else {
            wp_register_style('userpro_skin_min', userpro_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        }
        if (locate_template('userpro/skins/' . $skin . '/style.css')) {
            wp_register_style('userpro_skin_custom', get_template_directory_uri() . '/userpro/skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_custom');
        }
        include userpro_path . "css/userpro.php";
        /**
        			END THEMING
        		**/
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
}
Пример #6
0
 function can_view_private_content($restrict_to_verified = null, $restrict_to_roles = null)
 {
     if (!userpro_is_logged_in()) {
         return '-1';
     } else {
         if (userpro_get_option('restricted_page_verified') == "1" && $this->get_verified_status(get_current_user_id())) {
             $user = get_userdata(get_current_user_id());
             $user_role = array_shift($user->roles);
             if ($restrict_to_verified == 1 && $this->get_verified_status(get_current_user_id()) || $restrict_to_roles != '' && in_array($user_role, explode(',', $restrict_to_roles)) || !$restrict_to_verified && !$restrict_to_roles) {
                 return '1';
             } else {
                 return '-2';
             }
         } else {
             if (userpro_get_option('restricted_page_verified') == "0") {
                 $user = get_userdata(get_current_user_id());
                 $user_role = array_shift($user->roles);
                 if ($restrict_to_verified == 1 && $this->get_verified_status(get_current_user_id()) || $restrict_to_roles != '' && in_array($user_role, explode(',', $restrict_to_roles)) || !$restrict_to_verified && !$restrict_to_roles) {
                     return '1';
                 } else {
                     return '-2';
                 }
             }
         }
     }
 }
Пример #7
0
function userpro_process_form()
{
    global $userpro;
    if (!isset($_POST['_myuserpro_nonce']) || !wp_verify_nonce($_POST['_myuserpro_nonce'], '_myuserpro_nonce_' . $_POST['template'] . '_' . $_POST['unique_id'])) {
        die;
    }
    if (!isset($_POST) || $_POST['action'] != 'userpro_process_form') {
        die;
    }
    if (!userpro_is_logged_in() && $_POST['template'] == 'edit') {
        die;
    }
    extract($_POST);
    foreach ($_POST as $key => $val) {
        $key = explode('-', $key);
        $key = $key[0];
        $form[$key] = $val;
    }
    extract($form);
    /* form action */
    switch ($template) {
        /* publish */
        case 'publish':
            $output['error'] = '';
            if (!$post_title) {
                $output['error']['post_title'] = __('You must enter a post title.', 'userpro');
            }
            if (!$userpro_editor) {
                $output['error']['userpro_editor'] = __('You must enter some content.', 'userpro');
            }
            /*
            	publish post
            */
            if (empty($output['error'])) {
                $array = array('post_title' => $post_title, 'post_content' => @wp_kses($userpro_editor), 'post_author' => $user_id);
                if ($post_type) {
                    $array['post_type'] = $post_type;
                }
                if (userpro_is_admin($user_id)) {
                    $array['post_status'] = 'publish';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . sprintf(__('Your post has been published. You can view it %s.', 'userpro'), '<a href="' . get_permalink($post_id) . '">here</a>') . '</p></div>';
                } else {
                    // under review
                    $array['post_status'] = 'pending';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your post has been sent for review. It will be checked by our staff.', 'userpro') . '</p></div>';
                }
                /*
                	empty category first
                */
                wp_set_object_terms($post_id, NULL, 'category');
                /*
                	taxonomy
                	and category
                */
                if (isset($taxonomy) && isset($category)) {
                    $categories = explode(',', $category);
                    if (is_array($categories)) {
                        foreach ($categories as $cat) {
                            if (is_numeric($cat)) {
                                $cat = (int) $cat;
                            }
                            $cats[] = $cat;
                        }
                        wp_set_object_terms($post_id, $cats, $taxonomy);
                    } else {
                        if (is_numeric($categories)) {
                            $categories = (int) $categories;
                        }
                        wp_set_object_terms($post_id, $categories, $taxonomy);
                    }
                }
                /*
                	multiple taxonomy
                	category insertion
                */
                if (isset($post_categories)) {
                    $i = 0;
                    foreach ($post_categories as $cat) {
                        $i++;
                        $split = explode('#', $cat);
                        $tax = $split[1];
                        $id = $split[0];
                        $terms[$tax][] = $id;
                    }
                    if (is_array($terms)) {
                        foreach ($terms as $k => $arr) {
                            wp_set_object_terms($post_id, $terms[$k], $k, true);
                        }
                    }
                }
                /*
                	assign featured
                	image for post
                */
                if ($post_featured_image) {
                    $attach_id = $userpro->new_attachment($post_id, $post_featured_image);
                    $userpro->set_thumbnail($post_id, $attach_id);
                }
            }
            break;
            /* delete profile */
        /* delete profile */
        case 'delete':
            $output['error'] = '';
            $user = get_userdata($user_id);
            $user_roles = $user->roles;
            $user_role = array_shift($user_roles);
            if (!$confirmdelete) {
                $output['error']['confirmdelete'] = __('Nothing was deleted. You must choose yes to confirm deletion.', 'userpro');
            } elseif ($user_role == 'administrator') {
                $output['error']['confirmdelete'] = __('For security reasons, admin accounts cannot be deleted.', 'userpro');
            } elseif ($user->user_login == 'test') {
                $output['error']['confirmdelete'] = __('You cannot remove test accounts from frontend!', 'userpro');
            } else {
                require_once ABSPATH . 'wp-admin/includes/user.php';
                userpro_mail($user_id, 'accountdeleted');
                // Delete user
                if (is_multisite()) {
                    // Multisite: Deletes user's Posts and Links, then deletes from WP Users|Usermeta
                    // ONLY IF "Delete From Network" setting checked and user only belongs to this blog
                    wpmu_delete_user($user_id);
                } else {
                    // Deletes user's Posts and Links
                    // Multisite: Removes user from current blog
                    // Not Multisite: Deletes user from WP Users|Usermeta
                    wp_delete_user($user_id);
                }
                $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('This account has been deleted successfully.', 'userpro') . '</p></div>';
                $output['redirect_uri'] = home_url();
            }
            break;
            /* change pass */
        /* change pass */
        case 'change':
            $output['error'] = '';
            if (!$secretkey) {
                $output['error']['secretkey'] = __('You did not provide a secret key.', 'userpro');
            } elseif (strlen($secretkey) != 20) {
                $output['error']['secretkey'] = __('The secret key you entered is invalid.', 'userpro');
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            if (empty($output['error'])) {
                $users = get_users(array('meta_key' => 'userpro_secret_key', 'meta_value' => $secretkey, 'meta_compare' => '='));
                if (!$users[0]) {
                    $output['error']['secretkey'] = __('The secret key is invalid or expired.', 'userpro');
                } else {
                    $user_id = $users[0]->ID;
                    wp_update_user(array('ID' => $user_id, 'user_pass' => $user_pass));
                    delete_user_meta($user_id, 'userpro_secret_key');
                    add_action('userpro_pre_form_message', 'userpro_msg_login_after_passchange');
                    $shortcode = stripslashes($shortcode);
                    $modded = str_replace('template="change"', 'template="login"', $shortcode);
                    $output['template'] = do_shortcode($modded);
                }
            }
            break;
            /* send secret key */
        /* send secret key */
        case 'reset':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            } else {
                if (is_email($username_or_email)) {
                    $user = get_user_by_email($username_or_email);
                    $username_or_email = $user->user_login;
                }
                if (!username_exists($username_or_email)) {
                    $output['error']['username_or_email'] = __('There is not such user in our system.', 'userpro');
                } elseif (!$userpro->can_reset_pass($username_or_email)) {
                    $output['error']['username_or_email'] = __('Resetting admin password is not permitted!', 'userpro');
                }
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            /* email user with secret key and update
            			his user meta */
            if (empty($output['error'])) {
                $user = get_user_by('login', $username_or_email);
                $uniquekey = wp_generate_password(20, $include_standard_special_chars = false);
                update_user_meta($user->ID, 'userpro_secret_key', $uniquekey);
                userpro_mail($user->ID, 'secretkey', $uniquekey);
                add_action('userpro_pre_form_message', 'userpro_msg_secret_key_sent');
                $shortcode = stripslashes($shortcode);
                $modded = str_replace('template="reset"', 'template="change"', $shortcode);
                $output['template'] = do_shortcode($modded);
            }
            break;
            /* login */
        /* login */
        case 'login':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            }
            if (!$user_pass) {
                $output['error']['user_pass'] = __('You should provide your password.', 'userpro');
            }
            if (email_exists($username_or_email)) {
                $user = get_user_by('email', $username_or_email);
                $username_or_email = $user->user_login;
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_login_validation', $output['error'], $form);
            if (empty($output['error']) && $username_or_email && $user_pass) {
                $creds = array();
                $creds['user_login'] = $username_or_email;
                $creds['user_password'] = $user_pass;
                $creds['remember'] = true;
                $user = wp_signon($creds, false);
                if (is_wp_error($user)) {
                    if ($user->get_error_code() == 'invalid_username') {
                        $output['error']['username_or_email'] = __('Invalid email or username entered', 'userpro');
                    } elseif ($user->get_error_code() == 'incorrect_password') {
                        $output['error']['user_pass'] = __('The password you entered is incorrect', 'userpro');
                    }
                } else {
                    /* check the account is active first */
                    if ($userpro->is_pending($user->ID)) {
                        if (userpro_get_option('users_approve') === '2') {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your email is pending verification. Please activate your account.', 'userpro') . '</p></div>';
                        } else {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your account is currently being reviewed. Thanks for your patience.', 'userpro') . '</p></div>';
                        }
                        wp_logout();
                    } else {
                        /* a good login */
                        userpro_auto_login($user->user_login, true);
                        if (isset($force_redirect_uri) && !empty($force_redirect_uri)) {
                            $output['redirect_uri'] = 'refresh';
                        } else {
                            if (current_user_can('manage_options') && userpro_get_option('show_admin_after_login')) {
                                $output['redirect_uri'] = admin_url();
                            } else {
                                if (isset($redirect_uri) && !empty($redirect_uri)) {
                                    $output['redirect_uri'] = $redirect_uri;
                                } else {
                                    if (userpro_get_option('after_login') == 'no_redirect') {
                                        $output['redirect_uri'] = 'refresh';
                                    }
                                    if (userpro_get_option('after_login') == 'profile') {
                                        $output['redirect_uri'] = $userpro->permalink();
                                    }
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                        }
                        /* super redirection */
                        if (isset($global_redirect)) {
                            $output['redirect_uri'] = $global_redirect;
                        }
                    }
                    // active/pending
                }
            }
            break;
            /* editing */
        /* editing */
        case 'edit':
            if ($user_id != get_current_user_id() && !current_user_can('manage_options')) {
                die;
            }
            userpro_update_user_profile($user_id, $form, $action = 'ajax_save');
            if (userpro_get_option('notify_admin_profile_save') && !current_user_can('manage_options')) {
                userpro_mail($user_id, 'profileupdate', null, $form);
            }
            add_action('userpro_pre_form_message', 'userpro_msg_profile_saved');
            if ($_POST['up_username']) {
                set_query_var('up_username', $_POST['up_username']);
            }
            $shortcode = stripslashes($shortcode);
            $modded = $shortcode;
            $output['template'] = do_shortcode($modded);
            break;
            /* registering */
        /* registering */
        case 'register':
            $output['error'] = '';
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_register_validation', $output['error'], $form);
            if (empty($output['error']) && (isset($user_login) && isset($user_email) && isset($user_pass) || isset($user_login) && isset($user_email) || isset($user_email))) {
                if (isset($user_login)) {
                    $user_exists = username_exists($user_login);
                } else {
                    $user_exists = username_exists('the_cow_that_did_run_after_the_elephant');
                    $user_login = $user_email;
                }
                if (!isset($user_exists) and email_exists($user_email) == false) {
                    if (!isset($user_pass)) {
                        $user_pass = wp_generate_password($length = 12, $include_standard_special_chars = false);
                    }
                    /* not auto approved? */
                    if (userpro_get_option('users_approve') !== '1') {
                        /* require email validation */
                        if (userpro_get_option('users_approve') === '2') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_email_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                        /* require admin validation */
                        if (userpro_get_option('users_approve') === '3') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_admin_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending_admin');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    } else {
                        $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard');
                        /* auto login */
                        if (userpro_get_option('after_register_autologin')) {
                            $creds = array();
                            $creds['user_login'] = $user_login;
                            $creds['user_password'] = $user_pass;
                            $creds['remember'] = true;
                            $user = wp_signon($creds, false);
                            if (isset($user->user_login)) {
                                userpro_auto_login($user->user_login, true);
                            }
                            if ($redirect_uri) {
                                $output['redirect_uri'] = $redirect_uri;
                            } else {
                                if (userpro_get_option('after_register') == 'no_redirect') {
                                    $output['redirect_uri'] = 'refresh';
                                }
                                if (userpro_get_option('after_register') == 'profile') {
                                    $output['redirect_uri'] = $userpro->permalink();
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_register_redirect', $output['redirect_uri']);
                            /* manual login form */
                        } else {
                            add_action('userpro_pre_form_message', 'userpro_msg_login_after_reg');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    }
                }
            }
            break;
    }
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}
Пример #8
0
function userpro_show_new_notification()
{
    global $userpro_msg;
    if (userpro_is_logged_in()) {
        $user_id = get_current_user_id();
        if ($userpro_msg->has_new_chats($user_id)) {
            require_once userpro_msg_path . 'templates/notification.php';
        }
    }
}
Пример #9
0
function userpro_redirects()
{
    global $pagenow;
    // redirect dashboard
    if ('index.php' == $pagenow && is_admin()) {
        if (userpro_is_logged_in() && userpro_allow_dashboard_redirect()) {
            wp_redirect(userpro_dashboard_redirect_uri());
            exit;
        }
    }
    // redirect dashboard profile
    if ('profile.php' == $pagenow) {
        if (userpro_is_logged_in() && userpro_allow_profile_redirect()) {
            wp_redirect(userpro_profile_redirect_uri());
            exit;
        }
    }
    // redirect login
    if ('wp-login.php' == $pagenow && !isset($_REQUEST['action'])) {
        if (userpro_allow_login_redirect()) {
            if (isset($_GET['redirect_to'])) {
                $url = add_query_arg('redirect_to', $_GET['redirect_to'], userpro_login_redirect_uri());
            } else {
                $url = userpro_login_redirect_uri();
            }
            wp_redirect($url);
            exit;
        }
    }
    // redirect lostpassword
    if ('wp-login.php' == $pagenow && isset($_REQUEST['action']) && $_REQUEST['action'] == 'lostpassword') {
        if (userpro_allow_login_redirect()) {
            wp_redirect(userpro_login_redirect_uri());
            exit;
        }
    }
    // redirect register
    if ('wp-login.php' == $pagenow && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register') {
        if (userpro_allow_register_redirect()) {
            wp_redirect(userpro_register_redirect_uri());
            exit;
        }
    }
}
Пример #10
0
function userpro_fbconnect()
{
    global $userpro;
    $output = '';
    if (!isset($_POST)) {
        die;
    }
    if ($_POST['action'] != 'userpro_fbconnect') {
        die;
    }
    if (!isset($_POST['id'])) {
        die;
    }
    extract($_POST);
    if (!isset($username) || $username == '' || $username == 'undefined') {
        $username = $email;
    }
    /* Check if facebook uid exists */
    if (isset($id) && $id != '' && $id != 'undefined') {
        $users = get_users(array('meta_key' => 'userpro_facebook_id', 'meta_value' => $id, 'meta_compare' => '='));
        if (isset($users[0]->ID) && is_numeric($users[0]->ID)) {
            $returning = $users[0]->ID;
            $returning_user_login = $users[0]->user_login;
        } else {
            $returning = '';
        }
    } else {
        $returning = '';
    }
    $result = get_user_meta($returning, "userpayment");
    $paymentoption = get_option('userpro_payment');
    /* Check if user is logged in */
    if (userpro_is_logged_in()) {
        $userpro->update_fb_id(get_current_user_id(), $id);
        if ($redirect == '') {
            $output['redirect_uri'] = 'refresh';
        } elseif ($redirect != 'profile') {
            $output['redirect_uri'] = $redirect;
        } else {
            $output['redirect_uri'] = $userpro->permalink();
        }
        $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
    } else {
        if ($returning != '') {
            if ($paymentoption['userpro_payment_option'] == 'y') {
                if ($result[0] == "recive" || $result[0] == "") {
                    userpro_auto_login($returning_user_login, true);
                    $userpro->update_fb_id($returning, $id);
                    if ($redirect == '') {
                        $output['redirect_uri'] = 'refresh';
                    } elseif ($redirect != 'profile') {
                        $output['redirect_uri'] = $redirect;
                    } else {
                        $output['redirect_uri'] = $userpro->permalink();
                    }
                    $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                } else {
                    !empty($output['paypal_form']) ? $out = $output['paypal_form'] : ($out = '');
                    $output['paypal_form'] = apply_filters('paymentredirect', $out, $returning);
                }
            } else {
                userpro_auto_login($returning_user_login, true);
                if ($redirect == '') {
                    $output['redirect_uri'] = 'refresh';
                } elseif ($redirect != 'profile') {
                    $output['redirect_uri'] = $redirect;
                } else {
                    $output['redirect_uri'] = $userpro->permalink();
                }
                $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
            }
            /* Email is same, connect them together */
        } else {
            if ($email != '' && email_exists($email)) {
                $user_id = email_exists($email);
                $user = get_userdata($user_id);
                $result = get_user_meta($user_id, "userpayment");
                $paymentoption = get_option('userpro_payment');
                if ($paymentoption['userpro_payment_option'] == 'y') {
                    if (isset($result[0]) && $result[0] == "recive" || $result[0] == "") {
                        userpro_auto_login($user->user_login, true);
                        $userpro->update_fb_id($user_id, $id);
                        if ($redirect == '') {
                            $output['redirect_uri'] = 'refresh';
                        } elseif ($redirect != 'profile') {
                            $output['redirect_uri'] = $redirect;
                        } else {
                            $output['redirect_uri'] = $userpro->permalink();
                        }
                        $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                    } else {
                        !empty($output['paypal_form']) ? $out = $output['paypal_form'] : ($out = '');
                        $output['paypal_form'] = apply_filters('paymentredirect', $out, $user_id);
                    }
                } else {
                    userpro_auto_login($user->user_login, true);
                    $userpro->update_fb_id($user_id, $id);
                    if ($redirect == '') {
                        $output['redirect_uri'] = 'refresh';
                    } elseif ($redirect != 'profile') {
                        $output['redirect_uri'] = $redirect;
                    } else {
                        $output['redirect_uri'] = $userpro->permalink();
                    }
                    $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                }
                /* This user already exists! connect them together */
            } else {
                if ($username != '' && username_exists($username)) {
                    $user_id = username_exists($username);
                    $user = get_userdata($user_id);
                    if ($paymentoption['userpro_payment_option'] == 'y') {
                        if ($result[0] == "recive" || $result[0] == "") {
                            userpro_auto_login($user->user_login, true);
                            $userpro->update_fb_id($user_id, $id);
                            if ($redirect == '') {
                                $output['redirect_uri'] = 'refresh';
                            } elseif ($redirect != 'profile') {
                                $output['redirect_uri'] = $redirect;
                            } else {
                                $output['redirect_uri'] = $userpro->permalink();
                            }
                            $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                        } else {
                            !empty($output['paypal_form']) ? $out = $output['paypal_form'] : ($out = '');
                            $output['paypal_form'] = apply_filters('paymentredirect', $out, $user_id);
                        }
                    } else {
                        userpro_auto_login($user->user_login, true);
                        $userpro->update_fb_id($user_id, $id);
                        if ($redirect == '') {
                            $output['redirect_uri'] = 'refresh';
                        } elseif ($redirect != 'profile') {
                            $output['redirect_uri'] = $redirect;
                        } else {
                            $output['redirect_uri'] = $userpro->permalink();
                        }
                        $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                    }
                    /* FBID not found, email/user not found - fresh user */
                } else {
                    if ($email !== 'undefined') {
                        $result = get_option('userpro_payment');
                        if ($result['userpro_payment_option'] == 'y') {
                            $user_pass = wp_generate_password($length = 12, $include_standard_special_chars = false);
                            $user_id = $userpro->new_user($username, $user_pass, $email, $_POST, $type = 'facebook');
                            update_user_meta($user_id, "userpayment", "notrecive");
                            $userpro->pending_admin_approve($user_id, $user_pass, $form = "");
                            !empty($output['paypal_form']) ? $out = $output['paypal_form'] : ($out = '');
                            $output['paypal_form'] = apply_filters('paymentredirect', $out, $user_id);
                        } else {
                            $user_pass = wp_generate_password($length = 12, $include_standard_special_chars = false);
                            $user_id = $userpro->new_user($username, $user_pass, $email, $_POST, $type = 'facebook');
                            userpro_auto_login($username, true);
                            if ($redirect == '') {
                                $output['redirect_uri'] = 'refresh';
                            } elseif ($redirect != 'profile') {
                                $output['redirect_uri'] = $redirect;
                            } else {
                                $output['redirect_uri'] = $userpro->permalink();
                            }
                            $output['redirect_uri'] = apply_filters('userpro_register_redirect', $output['redirect_uri']);
                        }
                    }
                }
            }
        }
    }
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}
Пример #11
0
function userpro_update_profile_via_facebook($user_id, $array)
{
    global $userpro;
    $id = isset($array['id']) ? $array['id'] : 0;
    $first_name = isset($array['first_name']) ? $array['first_name'] : 0;
    $last_name = isset($array['last_name']) ? $array['last_name'] : 0;
    $gender = isset($array['gender']) ? $array['gender'] : 0;
    $link = isset($array['link']) ? $array['link'] : 0;
    $email = isset($array['email']) ? $array['email'] : 0;
    $username = isset($array['username']) ? $array['username'] : 0;
    if (userpro_is_logged_in() && $user_id != get_current_user_id() && !current_user_can('manage_options')) {
        die;
    }
    if ($id && $id != 'undefined') {
        update_user_meta($user_id, 'userpro_facebook_id', $id);
    }
    if ($first_name && $first_name != 'undefined') {
        update_user_meta($user_id, 'first_name', $first_name);
    }
    if ($last_name && $last_name != 'undefined') {
        update_user_meta($user_id, 'last_name', $last_name);
    }
    if ($gender && $gender != 'undefined') {
        update_user_meta($user_id, 'gender', $gender);
    }
    if ($link && $link != 'undefined') {
        update_user_meta($user_id, 'facebook', $link);
    }
    /* begin display name */
    if (isset($name) && $name != 'undefined' && $name != 0) {
        $display_name = $name;
    } else {
        if ($first_name && $last_name && $first_name != 'undefined' && $last_name != 'undefined') {
            $display_name = $first_name . ' ' . $last_name;
        } else {
            if ($email) {
                $display_name = $email;
            } else {
                $display_name = $username;
            }
        }
    }
    if ($display_name) {
        if ($userpro->display_name_exists($display_name)) {
            $display_name = $userpro->unique_display_name($display_name);
        }
        $display_name = $userpro->remove_denied_chars($display_name);
        wp_update_user(array('ID' => $user_id, 'display_name' => $display_name));
        update_user_meta($user_id, 'display_name', $display_name);
    }
    /* end display name */
    do_action('userpro_after_profile_updated_fb');
}
Пример #12
0
function userpro_sc_shortcodes($args)
{
    global $userpro, $userpro_social;
    extract($args);
    if (!userpro_get_option('modstate_social')) {
        return false;
    }
    $query_id = userpro_get_view_user(get_query_var('up_username'));
    $user_id = get_current_user_id();
    // show activity
    if (isset($args['template']) && $args['template'] == 'activity') {
        // ALL ACTIVITY
        if ($args['activity_all'] == 1) {
            // ACTIVITY OPEN TO ALL
            if (userpro_sc_get_option('activity_open_to_all') == 1) {
                $activity = $userpro_social->activity(0, 0, $args['activity_per_page'], $args['activity_user']);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_sc_path . "templates/{$template}.php";
                }
            } else {
                if (userpro_is_logged_in()) {
                    $activity = $userpro_social->activity(0, 0, $args['activity_per_page'], $args['activity_user']);
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_sc_path . "templates/{$template}.php";
                    }
                } else {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
            }
            // FOLLOWED ACTIVITY
        } else {
            if (userpro_is_logged_in()) {
                if ($user_id == $query_id) {
                    $activity = $userpro_social->activity($user_id, 0, $args['activity_per_page'], $args['activity_user']);
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_sc_path . "templates/{$template}.php";
                    }
                } else {
                    // show nothing
                }
            } else {
                /* attempt to view profile so force redirect to same page */
                $args['force_redirect_uri'] = 1;
                $template = 'login';
                $args['template'] = 'login';
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/login.php";
                }
            }
        }
    }
    // show users I am following
    if (isset($args['template']) && $args['template'] == 'following') {
        if (userpro_is_logged_in()) {
            $user_id = $userpro->try_query_user($user_id);
            $following = $userpro_social->following($user_id);
            if (locate_template('userpro/' . $template . '.php') != '') {
                include get_template_directory() . '/userpro/' . $template . '.php';
            } else {
                include userpro_sc_path . "templates/{$template}.php";
            }
        } else {
            /* attempt to view profile so force redirect to same page */
            $args['force_redirect_uri'] = 1;
            $template = 'login';
            $args['template'] = 'login';
            if (locate_template('userpro/' . $template . '.php') != '') {
                include get_template_directory() . '/userpro/' . $template . '.php';
            } else {
                include userpro_path . "templates/login.php";
            }
        }
        $userpro->temp_id = $user_id;
    }
    // show followers
    if (isset($args['template']) && $args['template'] == 'followers') {
        if (userpro_is_logged_in()) {
            $user_id = $userpro->try_query_user($user_id);
            $followers = $userpro_social->followers($user_id);
            if (locate_template('userpro/' . $template . '.php') != '') {
                include get_template_directory() . '/userpro/' . $template . '.php';
            } else {
                include userpro_sc_path . "templates/{$template}.php";
            }
        } else {
            /* attempt to view profile so force redirect to same page */
            $args['force_redirect_uri'] = 1;
            $template = 'login';
            $args['template'] = 'login';
            if (locate_template('userpro/' . $template . '.php') != '') {
                include get_template_directory() . '/userpro/' . $template . '.php';
            } else {
                include userpro_path . "templates/login.php";
            }
        }
        $userpro->temp_id = $user_id;
    }
}
Пример #13
0
 function follow_text($to, $from)
 {
     $body = '';
     $caption = '';
     $link = '';
     $name = '';
     $description = '';
     if ($to != $from && userpro_is_logged_in()) {
         /** Facebook Auto Post Bring Back , Added By Rahul */
         if (userpro_get_option('facebook_follow_autopost')) {
             if (userpro_get_option('facebook_follow_autopost_name')) {
                 $name = userpro_get_option('facebook_follow_autopost_name');
                 // post title
             } else {
                 $name = '';
             }
             if (userpro_get_option('facebook_follow_autopost_body')) {
                 $body = userpro_get_option('facebook_follow_autopost_body');
                 // post body
             } else {
                 $body = '';
             }
             if (userpro_get_option('facebook_follow_autopost_caption')) {
                 $caption = userpro_get_option('facebook_follow_autopost_caption');
                 // caption, url, etc.
             } else {
                 $caption = '';
             }
             if (userpro_get_option('facebook_follow_autopost_description')) {
                 $description = userpro_get_option('facebook_follow_autopost_description');
                 // full description
             } else {
                 $description = '';
             }
             if (userpro_get_option('facebook_follow_autopost_link')) {
                 $link = userpro_get_option('facebook_follow_autopost_link');
                 // link
             } else {
                 $link = '';
             }
         }
         $iamfollowing = get_user_meta($from, '_userpro_following_ids', true);
         if (isset($iamfollowing[$to])) {
             return '<a href="#" class="userpro-button userpro-follow following" data-follow-text="' . __('Follow', 'userpro') . '" data-unfollow-text="' . __('Unfollow', 'userpro') . '" data-following-text="' . __('Following', 'userpro') . '" data-follow-to="' . $to . '" data-follow-from="' . $from . '">' . __('Following', 'userpro') . '</a>';
         } else {
             return '<a href="#" class="userpro-button secondary userpro-follow notfollowing" data-follow-text="' . __('Follow', 'userpro') . '" data-unfollow-text="' . __('Unfollow', 'userpro') . '" data-following-text="' . __('Following', 'userpro') . '" data-follow-to="' . $to . '" data-follow-from="' . $from . '" id="fb-post-data" data-fbappid="' . userpro_get_option('facebook_app_id') . '" data-message="' . $body . '" data-caption="' . $caption . '" data-link="' . $link . '" data-name="' . $name . '" data-description="' . $description . '" ><i class="userpro-icon-share"></i>' . __('Follow', 'userpro') . '</a>';
         }
     }
 }
Пример #14
0
function userpro_broadcast()
{
    global $userpro, $userpro_msg;
    $output = '';
    extract($_POST);
    if (!userpro_is_logged_in() || $user_id != get_current_user_id()) {
        die;
    }
    $user_id = get_current_user_id();
    $registered_users = explode(",", $user_list);
    $no_of_users -= 1;
    if ($registered_users[$user_no] != $user_id) {
        $userpro_msg->do_chat_dir($registered_users[$user_no], $user_id, $mode = 'inbox');
        $userpro_msg->write_chat($registered_users[$user_no], $user_id, $broadcast_body, $mode = 'inbox');
        $userpro_msg->email_user($registered_users[$user_no], $user_id, $broadcast_body);
        if (isset($_SESSION['user_count'])) {
            $_SESSION['user_count'] += 1;
        } else {
            $_SESSION['user_count'] = 1;
        }
        $output['message'] = '<div class="userpro-msg-notice">' . __('Your message has been sent to ' . userpro_profile_data('display_name', $registered_users[$user_no]) . '.', 'userpro-msg') . '</div><div class="userpro-msg-notice">' . __('Message sent to ' . $_SESSION['user_count'] . ' out of ' . $no_of_users . ' users.', 'userpro-msg') . '</div>';
        if ($_SESSION['user_count'] >= $no_of_users) {
            unset($_SESSION['user_count']);
            $userpro_msg->email_broadcaster($user_id, $broadcast_body);
            $output['message'] .= '<div class="userpro-msg-notice">' . __('Your message has been broadcasted successfully.', 'userpro-msg') . '</div>';
        }
        $output = json_encode($output);
        if (is_array($output)) {
            print_r($output);
        } else {
            echo $output;
        }
        die;
    } else {
        $output['message'] = '';
        $output = json_encode($output);
        if (is_array($output)) {
            print_r($output);
        } else {
            echo $output;
        }
        die;
    }
}
Пример #15
0
function userpro($args = array())
{
    global $post, $wp, $userpro_admin, $userpro;
    $argument = $args;
    if (is_home()) {
        $permalink = home_url();
    } else {
        if (isset($post->ID)) {
            $permalink = get_permalink($post->ID);
        } else {
            $permalink = '';
        }
    }
    /* arguments */
    /* Deafult Args */
    $default_args = array('modal_profile_saved' => __('Your profile has been saved!', 'userpro'), 'template' => null, 'max_width' => userpro_get_option('width'), 'uploads_dir' => $userpro->get_uploads_url(), 'default_avatar_male' => userpro_url . 'img/default_avatar_male.jpg', 'default_avatar_female' => userpro_url . 'img/default_avatar_female.jpg', 'layout' => userpro_get_option('layout'), 'margin_top' => 0, 'margin_bottom' => '30px', 'align' => 'center', 'skin' => userpro_get_option('skin'), 'required_text' => __('This field is required', 'userpro'), 'password_too_short' => __('Your password is too short', 'userpro'), 'passwords_do_not_match' => __('Passwords do not match', 'userpro'), 'password_not_strong' => __('Password is not strong enough', 'userpro'), 'keep_one_section_open' => 0, 'allow_sections' => 1, 'permalink' => $permalink, 'field_icons' => userpro_get_option('field_icons'), 'profile_thumb_size' => 80, 'register_heading' => __('Register an Account', 'userpro'), 'register_side' => __('Already a member?', 'userpro'), 'register_side_action' => 'login', 'register_button_action' => 'login', 'register_button_primary' => __('Register', 'userpro'), 'register_button_secondary' => __('Login', 'userpro'), 'register_group' => 'default', 'register_redirect' => '', 'type' => userpro_mu_get_option('multi_forms_default'), 'force_redirect_uri' => 0, 'login_heading' => __('Login', 'userpro'), 'login_side' => __('Forgot your password?', 'userpro'), 'login_side_action' => 'reset', 'login_button_action' => 'register', 'login_button_primary' => __('Login', 'userpro'), 'login_button_secondary' => __('Create an Account', 'userpro'), 'login_group' => 'default', 'login_redirect' => '', 'rememberme' => 'true', 'delete_heading' => __('Delete Profile', 'userpro'), 'delete_side' => __('Undo, back to profile', 'userpro'), 'delete_side_action' => 'view', 'delete_button_action' => 'view', 'delete_button_primary' => __('Confirm Deletion', 'userpro'), 'delete_button_secondary' => __('Back to Profile', 'userpro'), 'delete_group' => 'default', 'reset_heading' => __('Reset Password', 'userpro'), 'reset_side' => __('Back to Login', 'userpro'), 'reset_side_action' => 'login', 'reset_button_action' => 'change', 'reset_button_primary' => __('Request Secret Key', 'userpro'), 'reset_button_secondary' => __('Change your Password', 'userpro'), 'reset_group' => 'default', 'change_heading' => __('Change your Password', 'userpro'), 'change_side' => __('Request New Key', 'userpro'), 'change_side_action' => 'reset', 'change_button_action' => 'reset', 'change_button_primary' => __('Change my Password', 'userpro'), 'change_button_secondary' => __('Do not have a secret key?', 'userpro'), 'change_group' => 'default', 'list_heading' => __('Latest Members', 'userpro'), 'list_per_page' => 5, 'list_sortby' => 'registered', 'list_order' => 'desc', 'list_users' => '', 'list_group' => 'default', 'list_thumb' => 50, 'list_showthumb' => 1, 'list_showsocial' => 1, 'list_showbio' => 0, 'list_verified' => 0, 'list_relation' => 'or', 'online_heading' => __('Who is online now', 'userpro'), 'online_thumb' => 30, 'online_showthumb' => 1, 'online_showsocial' => 0, 'online_showbio' => 0, 'online_mini' => 1, 'online_mode' => 'vertical', 'edit_button_primary' => __('Save Changes', 'userpro'), 'edit_group' => 'default', 'view_group' => 'default', 'social_target' => '_blank', 'social_group' => 'default', 'card_width' => '250px', 'card_img_width' => '250', 'card_showbio' => 1, 'card_showsocial' => 1, 'link_target' => '_blank', 'error_heading' => __('An error has occured', 'userpro'), 'memberlist_table' => 0, 'memberlist_table_columns' => 'user_id,picture,name,country,gender,role,email_user,message_user', 'show_on_mobile' => 'picture,name,country,email_user,message_user', 'memberlist_v2' => 1, 'memberlist_v2_pic_size' => '86', 'memberlist_v2_fields' => 'age,gender,country', 'memberlist_v2_bio' => 1, 'memberlist_v2_showbadges' => 1, 'memberlist_v2_showname' => 1, 'memberlist_v2_showsocial' => 1, 'memberlist_pic_size' => '120', 'memberlist_pic_topspace' => '15', 'memberlist_pic_sidespace' => '30', 'memberlist_pic_rounded' => 1, 'memberlist_width' => '100%', 'memberlist_paginate' => 1, 'memberlist_paginate_top' => 1, 'memberlist_paginate_bottom' => 1, 'memberlist_show_name' => 1, 'memberlist_popup_view' => 0, 'memberlist_withavatar' => 0, 'memberlist_verified' => 0, 'memberlist_filters' => '', 'memberlist_default_search' => 1, 'per_page' => 12, 'sortby' => 'registered', 'order' => 'desc', 'relation' => 'and', 'search' => 1, 'exclude' => '', 'show_social' => 1, 'registration_closed_side' => __('Existing member? login', 'userpro'), 'registration_closed_side_action' => 'login', 'facebook_redirect' => 'profile', 'logout_redirect' => '', 'post_paginate' => 1, 'postsbyuser_num' => '12', 'postsbyuser_types' => 'post', 'postsbyuser_mode' => 'grid', 'postsbyuser_thumb' => 50, 'postsbyuser_showthumb' => 1, 'postsbyuser_taxonomy' => 'category', 'postsbyuser_category' => '', 'following_per_page' => '4', 'following_paginate' => '1', 'followers_per_page' => '4', 'followers_paginate' => '1', 'publish_heading' => __('Add a New Post', 'userpro'), 'publish_button_primary' => __('Publish', 'userpro'));
    $defaults = apply_filters('userpro_shortcode_args', $default_args);
    $args = wp_parse_args($args, $defaults);
    /* The arguments are passed via shortcode through admin panel*/
    foreach ($default_args as $key => $val) {
        if (isset($args[$key])) {
            ${$key} = $args[$key];
        } else {
            ${$key} = $val;
        }
    }
    if ($template) {
        static $i = 0;
        ob_start();
        /* increment wall */
        $i = rand(1, 1000);
        /* user template */
        do_action('userpro_custom_template_hook', array_merge($args, array('i' => $i)));
        if (isset($argument['hide_content']) && $argument['hide_content'] && empty($_GET)) {
            if (!empty($argument)) {
                $parameters = '';
                $argument_length = count($argument);
                foreach ($argument as $key => $value) {
                    if ($key == 'hide_content') {
                        continue;
                    }
                    $parameters .= " " . $key . "=" . "{$value}";
                }
            }
            $output = '<div class=userpro_show_content data-parameters="' . $parameters . '" ><a href="#">Click here to view the content</a></div>';
            return $output;
        } else {
            if (isset($argument['hide_content']) && $argument['hide_content']) {
                $template = $template;
            }
        }
        switch ($template) {
            case 'publish':
                if (userpro_is_logged_in()) {
                    $user_id = get_current_user_id();
                    $layout = 'none';
                    $args['layout'] = 'none';
                    if (isset($args['deny_roles']) && !empty($args['deny_roles'])) {
                        $denied_roles = explode(',', $args['deny_roles']);
                        if ($userpro->user_role_in_array($user_id, $denied_roles)) {
                            if (locate_template('userpro/not_allowed.php') != '') {
                                include get_stylesheet_directory() . '/userpro/not_allowed.php';
                            } else {
                                include userpro_path . "templates/not_allowed.php";
                            }
                        } else {
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                    } else {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    add_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                    remove_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                }
                break;
            case 'postsbyuser':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        if (is_author()) {
                            $user_id = get_query_var('author');
                        } else {
                            $user_id = get_the_author_meta('ID');
                        }
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    if (isset($args['user_id'])) {
                        $user_id = $args['user_id'];
                    } else {
                        $user_id = userpro_get_view_user(get_query_var('up_username'));
                    }
                }
                $totalposts = count_user_posts($user_id);
                $paginate = paginate_links(array('base' => add_query_arg('postp', '%#%'), 'total' => ceil($totalposts / $args['postsbyuser_num']), 'current' => isset($_GET['postp']) ? $_GET['postp'] : 1, 'show_all' => false, 'end_size' => 1, 'mid_size' => 2, 'prev_next' => true, 'prev_text' => __('« Previous', 'userpro'), 'next_text' => __('Next »', 'userpro'), 'type' => 'plain', 'add_args' => false));
                $is_paginate = $args['post_paginate'];
                if ($is_paginate == 0) {
                    $args['postsbyuser_num'] = $totalposts;
                }
                $post_query = $userpro->posts_by_user($user_id, $args);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                wp_reset_query();
                break;
            case 'online':
                $users = $userpro->onlineusers();
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'request_verify':
                $userpro->new_verification_request($_POST['up_username']);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'reset':
                add_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                remove_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                break;
            case 'change':
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'delete':
                if (isset($args['user'])) {
                    $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ((int) $user_id) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'memberlist':
                $users = userpro_memberlist_loop($args);
                if ($args['memberlist_table'] == 1) {
                    $template = 'memberlist_table';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } elseif ($args['memberlist_v2'] == 0) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (locate_template('userpro/' . $template . '_v2.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '_v2.php';
                    } else {
                        include userpro_path . "templates/{$template}" . "_v2.php";
                    }
                }
                break;
            case 'list':
                $users = userpro_memberlist_listusers($args, $list_users);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'card':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        if (is_author()) {
                            $user_id = get_query_var('author');
                        } else {
                            $user_id = get_the_author_meta('ID');
                        }
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                    if (!$user_id && userpro_is_logged_in()) {
                        $user_id = get_current_user_id();
                    }
                }
                if ($user_id) {
                    $get_user = get_userdata($user_id);
                    $user = $get_user->user_login;
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
            case 'register':
                if (userpro_get_option('userpro_invite_emails_enable') == 1 && !isset($_GET['code'])) {
                    $template = 'registration_closed';
                    $args['template'] = 'registration_closed';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (isset($_GET['code']) && $_GET['code'] != '' && userpro_get_option('userpro_invite_emails_enable') == 1) {
                        $codes = get_option('userpro_invited_users');
                        if (isset($codes[urldecode($_GET['code'])]) && hash_equals(urldecode($_GET['code']), crypt($codes[urldecode($_GET['code'])], urldecode($_GET['code'])))) {
                            if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_register')) {
                                if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                                    if (locate_template('userpro/' . $template . '.php') != '') {
                                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                                    } else {
                                        include userpro_path . "templates/{$template}.php";
                                    }
                                }
                            } else {
                                $user_id = get_current_user_id();
                                if (locate_template('userpro/logout.php') != '') {
                                    include get_stylesheet_directory() . '/userpro/logout.php';
                                } else {
                                    include userpro_path . "templates/logout.php";
                                }
                            }
                        } else {
                            $template = 'registration_closed';
                            $args['template'] = 'registration_closed';
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                        break;
                    }
                    if (userpro_get_option('users_can_register') == 0) {
                        $template = 'registration_closed';
                        $args['template'] = 'registration_closed';
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    } else {
                        if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_register')) {
                            if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                                if (locate_template('userpro/' . $template . '.php') != '') {
                                    include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                                } else {
                                    include userpro_path . "templates/{$template}.php";
                                }
                            }
                        } else {
                            $user_id = get_current_user_id();
                            if (locate_template('userpro/logout.php') != '') {
                                include get_stylesheet_directory() . '/userpro/logout.php';
                            } else {
                                include userpro_path . "templates/logout.php";
                            }
                        }
                    }
                }
                break;
            case 'login':
                if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_login')) {
                    if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    $user_id = get_current_user_id();
                    if (locate_template('userpro/logout.php') != '') {
                        include get_stylesheet_directory() . '/userpro/logout.php';
                    } else {
                        include userpro_path . "templates/logout.php";
                    }
                }
                break;
            case 'edit':
                if (userpro_get_edit_user()) {
                    $user_id = userpro_get_edit_user();
                    if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                        if (locate_template('userpro/' . $user_id . '.php') != '') {
                            include get_stylesheet_directory() . '/userpro/' . $user_id . '.php';
                        } else {
                            include userpro_path . "templates/{$user_id}.php";
                        }
                    } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'view':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        if (is_author()) {
                            $user_id = get_query_var('author');
                        } else {
                            $user_id = get_the_author_meta('ID');
                        }
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ($user_id == 'login_to_view') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif ($user_id == 'login_to_view_others') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_stylesheet_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
        }
        /**
        		START THEMING
        		**/
        if (in_array($align, array('left', 'right'))) {
            echo '<div class="userpro-clear"></div>';
        }
        if (class_exists('userpro_sk_api') && is_dir(userpro_sk_path . 'skins/' . $skin)) {
            wp_register_style('userpro_skin_min', userpro_sk_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        } else {
            wp_register_style('userpro_skin_min', userpro_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        }
        if (locate_template('userpro/skins/' . $skin . '/style.css')) {
            wp_register_style('userpro_skin_custom', get_stylesheet_directory_uri() . '/userpro/skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_custom');
        }
        include userpro_path . "css/userpro.php";
        /**
        			END THEMING
        		**/
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
}
Пример #16
0
function userpro_redirects()
{
    global $pagenow;
    // redirect dashboard
    if ('index.php' == $pagenow && is_admin()) {
        if (userpro_is_logged_in() && userpro_allow_dashboard_redirect()) {
            wp_safe_redirect(userpro_dashboard_redirect_uri());
            exit;
        }
    }
    // redirect dashboard profile
    if ('profile.php' == $pagenow) {
        if (userpro_is_logged_in() && userpro_allow_profile_redirect()) {
            wp_safe_redirect(userpro_profile_redirect_uri());
            exit;
        }
    }
    // redirect login
    if ('wp-login.php' == $pagenow && !isset($_REQUEST['action'])) {
        if (!userpro_is_logged_in() && isset($_REQUEST['userpro_panic_key']) && userpro_get_option('userpro_panic_key') && $_REQUEST['userpro_panic_key'] == userpro_get_option('userpro_panic_key')) {
            return true;
        }
        if (userpro_allow_login_redirect()) {
            if (isset($_GET['redirect_to'])) {
                $url = add_query_arg('redirect_to', urlencode(esc_url($_GET['redirect_to'])), esc_url(userpro_login_redirect_uri()));
            } else {
                $url = userpro_login_redirect_uri();
            }
            wp_safe_redirect($url);
            exit;
        }
    }
    // redirect lostpassword
    if ('wp-login.php' == $pagenow && isset($_REQUEST['action']) && $_REQUEST['action'] == 'lostpassword') {
        if (userpro_allow_login_redirect()) {
            wp_safe_redirect(userpro_login_redirect_uri());
            exit;
        }
    }
    // redirect register
    if ('wp-login.php' == $pagenow && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register') {
        if (userpro_allow_register_redirect()) {
            wp_safe_redirect(userpro_register_redirect_uri());
            exit;
        }
    }
}
Пример #17
0
 function follow_text($to, $from)
 {
     if ($to != $from && userpro_is_logged_in()) {
         $iamfollowing = get_user_meta($from, '_userpro_following_ids', true);
         if (isset($iamfollowing[$to])) {
             return '<a href="#" class="userpro-button userpro-follow following" data-follow-text="' . __('Follow', 'userpro') . '" data-unfollow-text="' . __('Unfollow', 'userpro') . '" data-following-text="' . __('Following', 'userpro') . '" data-follow-to="' . $to . '" data-follow-from="' . $from . '">' . __('Following', 'userpro') . '</a>';
         } else {
             return '<a href="#" class="userpro-button secondary userpro-follow notfollowing" data-follow-text="' . __('Follow', 'userpro') . '" data-unfollow-text="' . __('Unfollow', 'userpro') . '" data-following-text="' . __('Following', 'userpro') . '" data-follow-to="' . $to . '" data-follow-from="' . $from . '"><i class="userpro-icon-share"></i>' . __('Follow', 'userpro') . '</a>';
         }
     }
 }
Пример #18
0
 function can_chat_with($user_id)
 {
     global $userpro_social;
     $global_privacy = userpro_msg_get_option('msg_privacy');
     if ($user_id != get_current_user_id() && userpro_is_logged_in()) {
         if ($global_privacy == 'none') {
             return false;
         }
         if ($global_privacy == 'public') {
             return true;
         } else {
             if ($global_privacy == 'mutual' && $userpro_social->mutual_follow(get_current_user_id(), $user_id)) {
                 return true;
             }
         }
     } else {
         return false;
     }
 }