Exemplo n.º 1
0
function userpro_global_page_restrict()
{
    global $userpro, $post;
    if (isset($post->ID)) {
        $go_to = userpro_get_option('restrict_url');
        $is_restricted = get_post_meta($post->ID, '_userpro_edit_restrict', true);
        $roles = get_post_meta($post->ID, 'restrict_roles', true);
        if ($is_restricted && $is_restricted != '') {
            // not logged in - not none
            if (isset($post->ID) && $is_restricted != 'none' && !userpro_is_logged_in() && get_permalink($post->ID) != $go_to && get_permalink($post->ID) != trailingslashit($go_to)) {
                wp_redirect(add_query_arg('redirect_to', get_permalink($post->ID), $go_to));
                exit;
            }
            // logged in (page set to verified accounts)
            if (isset($post->ID) && $is_restricted == 'verified' && userpro_is_logged_in() && !userpro_is_verified(get_current_user_id()) && get_permalink($post->ID) != $go_to && get_permalink($post->ID) != trailingslashit($go_to)) {
                wp_redirect(add_query_arg('redirect_to', get_permalink($post->ID), $go_to));
                exit;
            }
            // logged in (page set to specific roles)
            if (isset($post->ID) && $is_restricted == 'roles' && userpro_is_logged_in() && !$userpro->user_role_in_array(get_current_user_id(), (array) $roles) && get_permalink($post->ID) != $go_to && get_permalink($post->ID) != trailingslashit($go_to)) {
                wp_redirect(add_query_arg('redirect_to', get_permalink($post->ID), $go_to));
                exit;
            }
        }
    }
}
Exemplo n.º 2
0
function userpro_show_badges($user_id, $inline = false)
{
    global $current_user, $wp, $userpro, $userpro_vk;
    get_currentuserinfo();
    $output = null;
    /* verification beside name */
    if (userpro_get_option('verified_badge_by_name') && $userpro->get_verified_status($user_id) == 1) {
        $output .= userpro_get_badge('verified', '', $tooltip = 'right');
    }
    /* the badges wrap */
    if ($inline == true) {
        $output .= '<span class="userpro-badges inline">';
    } else {
        $output .= '<span class="userpro-badges">';
    }
    /* Verified */
    if (userpro_is_verified($user_id) && !userpro_get_option('verified_badge_by_name')) {
        $output .= userpro_get_badge('verified');
    }
    /* Show country flag */
    $output .= userpro_get_badge('country', $user_id);
    /* Facebook */
    if ($userpro->is_facebook_user($user_id)) {
        $output .= userpro_get_badge('facebook');
    }
    /* Twitter */
    if ($userpro->is_twitter_user($user_id)) {
        $output .= userpro_get_badge('twitter');
    }
    /* Google+ */
    if ($userpro->is_google_user($user_id)) {
        $output .= userpro_get_badge('google');
    }
    /* VK integration */
    if (class_exists('userpro_vk_api') && $userpro_vk->is_vk_user($user_id)) {
        $output .= $userpro_vk->userpro_get_badge('vk');
    }
    /* Envato */
    if ($userpro->is_envato_customer($user_id)) {
        $output .= userpro_get_badge('envato');
    }
    /* Custom defined badges */
    $badges = apply_filters('userpro_show_badges', $user_id);
    if ($badges != $user_id) {
        $output .= $badges;
    }
    /* Online/offline status */
    if (userpro_get_option('modstate_online')) {
        if ($userpro->is_user_online($user_id)) {
            $output .= userpro_get_badge('online');
        } else {
            if (userpro_get_option('modstate_showoffline')) {
                $output .= userpro_get_badge('offline');
            }
        }
    }
    $output .= '</span>';
    return $output;
}
Exemplo n.º 3
0
 function parse_column($col, $user_id, $user, $args)
 {
     global $userpro_msg;
     $output = null;
     $show_on_mobile = array('');
     if (isset($args['show_on_mobile'])) {
         $show_on_mobile = explode(',', $args['show_on_mobile']);
     }
     switch ($col) {
         case 'user_id':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="small ' . $col . ' ' . $mobile . '">' . $user_id . '</td>';
             break;
         case 'picture':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="thumb ' . $col . ' ' . $mobile . '"><div class="userpro-table-img"><a href="' . $this->permalink($user_id) . '">' . get_avatar($user_id, 36) . '</a></div></td>';
             break;
         case 'name':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="name ' . $col . ' ' . $mobile . '"><a href="' . $this->permalink($user_id) . '">' . userpro_profile_data('user_login', $user_id) . '</a> ';
             if (userpro_is_verified($user_id)) {
                 $output .= userpro_get_badge('verified');
             }
             $output .= '<br /><span class="nickname">(' . userpro_profile_data('display_name', $user_id) . ')</span></td>';
             break;
         case 'country':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="' . $col . ' ' . $mobile . '">' . userpro_get_badge('country_big', $user_id) . '</td>';
             break;
         case 'gender':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="' . $col . ' ' . $mobile . '">' . $this->cap_gender($user_id) . '</td>';
             break;
         case 'role':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="' . $col . ' ' . $mobile . '">' . $this->get_role_nice($user) . '</td>';
             break;
         case 'email_user':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="' . $col . ' ' . $mobile . '">';
             if (userpro_field_is_viewable('user_email', $user_id, $args)) {
                 $output .= '<a href="mailto:' . userpro_profile_data('user_email', $user_id) . '" class="userpro-flat-btn"><i class="userpro-icon-envelope"></i><span>' . __('Contact', 'userpro') . '</span></a>';
             }
             $output .= '</td>';
             break;
         case 'message_user':
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             if (class_exists('userpro_msg_api')) {
                 if ($userpro_msg->can_chat_with($user_id)) {
                     $output .= '<td class="' . $col . ' ' . $mobile . '"><a href="#" class="userpro-flat-btn chat userpro-init-chat" data-chat_with="' . $user_id . '" data-chat_from="' . get_current_user_id() . '"><i class="userpro-icon-comment"></i><span>' . __('Send Message', 'userpro-msg') . '</span>';
                     $output .= '</a></td>';
                 }
             }
             break;
         default:
             $value = get_user_meta($user_id, $col, true);
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (in_array($col, $show_on_mobile)) {
                 $mobile = 'show-on-mobile';
             } else {
                 $mobile = 'hide-on-mobile';
             }
             $output .= '<td class="' . $col . ' ' . $mobile . '">' . $value . '</td>';
             break;
     }
     return $output;
 }