Beispiel #1
0
function q_quserfilter($content)
{
    global $current_user;
    global $post;
    global $wpdb;
    if ($post->post_type != "quser") {
        return $content;
    }
    $content = "";
    if (isset($_GET['mess']) && $_GET['mess'] == 'Registered') {
        //display message to the user
        $content = "<p class='quser-message'>" . __('A password has been emailed to you', 'qna-forum') . "</p>";
    } elseif (isset($_GET['mess']) && $_GET['mess'] == 'PasswordsDontMatch') {
        $content = "<p class='quser-message'>" . __('Your passwords dont match', 'qna-forum') . "</p>";
    } elseif (isset($_GET['mess']) && $_GET['mess'] == 'ProfileUpdated') {
        $content = "<p class='quser-message'>" . __('Profile Updated', 'qna-forum') . "</p>";
    }
    //display for a logged in user
    get_currentuserinfo();
    if ($post->post_author == 1 && !is_user_logged_in() && get_option('q_registration_page') == 'TRUE' && get_option('q_quser_default_pageid') == $post->ID) {
        //Default page with no user means we need login/registration page
        $content .= "<h3>" . __('Login', 'qna-forum') . "</h3>" . wp_login_form(array('echo' => false)) . "<p>" . "<a href='" . wp_lostpassword_url("", "", false) . "'>" . __('Lost your password?', 'qna-forum') . "</a>";
        $content .= "<h3>" . __('Register', 'qna-forum') . "</h3>" . q_register_form(get_permalink(get_option('q_quser_default_pageid')) . "?mess=" . 'Registered');
        return $content;
    } elseif ($post->post_author == 1 && get_option('q_quser_default_pageid') == $post->ID) {
        $post->post_author = $current_user->ID;
    }
    $quser = get_userdata($post->post_author);
    //Display the user profile page
    $q_bestans = get_option('q_bestans');
    //create a table with number of question, answers and best answers
    if ($q_bestans == "TRUE") {
        $tdclass = "class='three-cols' style='width:83px;padding:3px 0;text-align:center;margin:0;'";
    } else {
        $tdclass = "class='two-cols' style='width:125px;padding:3px 0;text-align:center;margin:0;'";
    }
    $qatable = "<table class='quser-bestans'><tr><td {$tdclass}>" . __('Questions', 'qna-forum') . "</td><td {$tdclass}>" . __('Answers', 'qna-forum') . "</td>";
    if ($q_bestans == "TRUE") {
        $qatable .= "<td {$tdclass}>" . __('Best Answer', 'qna-forum') . "</td></tr>";
    } else {
        $qatable .= "</tr>";
    }
    $qatable .= "<tr><td {$tdclass}>" . get_user_meta($post->post_author, 'q_numqs', true) . "</td><td {$tdclass}>" . get_user_meta($post->post_author, 'q_numas', true) . "</td>";
    if ($q_bestans == "TRUE") {
        $qatable .= "<td {$tdclass}>" . get_user_meta($post->post_author, 'q_numbestas', true) . "</td></tr></table>";
    } else {
        $qatable .= "</tr></table>";
    }
    //Profile Decription - display in a paragraph if another user and allow editing if it is the current user
    if ($current_user->ID == $post->post_author) {
        //=======================================display editing form (note the inside of the html is repeated in quser-update.php)
        $desc = "";
        $desc .= "<p><a href='" . wp_logout_url() . "'>" . __('Logout', 'qna-forum') . "</a></p> \r\n\t\t\r\n\t\t\t<form class='quser-editdetails' id='quser_update_form' method='post' action='javascript:quser_update(\"quser_update_form\");'>\r\n\t\t\t" . q_quser_update_form($quser->description, "") . "\r\n\t\t\t\t</form>";
    } else {
        $desc = "<p>" . get_user_meta($post->post_author, 'description', TRUE) . "</p>";
    }
    //Query Sections
    $atts['questions'] = 5;
    $atts['author'] = $post->post_author;
    $qquery = q_list_questions($atts, "");
    $content .= "<div style='float:left;margin-right:20px'><div>" . get_avatar($quser->user_email, $size = '250', $default = '') . "</div>";
    $content .= "<p><a href='http://en.gravatar.com/emails/'>" . __('Get or Change your Gravatar', 'qna-forum') . "</a></p>";
    $content .= $qatable . "</div>";
    $content .= "<div id='quser-desc'><h3>" . __('About', 'qna-forum') . " " . $quser->display_name . "</h3>" . $desc . "</div>";
    $content .= "<h3 style='clear:both;margin-top:30px;'>" . __('My Recent Questions', 'qna-forum') . "</h3>";
    $content .= $qquery;
    return $content;
}
Beispiel #2
0
function q_db_widget()
{
    $atts['questions'] = 5;
    echo q_list_questions($atts, "");
}