Welcome to the Question2Answer Q&A. There's also a
demo
if you just want to try it out.
Login
Login
Register
All Activity
Questions
Hot!
Unanswered
Tags
Users
Ask a Question
About
Wiki
Welcome to the Q&A for
Question2Answer
.
If you have questions about the platform,
click here to ask
and please use English.
If you just want to try Q2A, please use the
demo
, which also grants admin access.
Jan 18:
1.5 release
Related questions
can i integrate it with moodle or joomla
Code to show related questions on wordpress posts.. I can pay for it...
error integrate with wordpress..why?
any one tried to integrate with wordpress?
How can I show ask box on wordpress site
How can I add multiple answers installation in a single wordpress?
How to integrate Question2Answer into a WordPress theme?
Can we integrate Connect with Facebook here?
Can one merge Q2A tag cloud with wordpress site tag cloud
Installation (integrating with wordpress) is not starting when I click 'Create Database'
All categories
Q2A Core
(2,732)
Plugins
(173)
How can I integrate it with wordpress?
+3
votes
I would like to know if it is possible to integrate this script with wordpress -joomla users database .
wordpress
joomla
asked
Apr 1, 2010
in
Q2A Core
by
anonymous
Even I would like to know how to integrate with Vbulletin forum.
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
2 Answers
+1
vote
You can do this with the single sign-on integration option, but it requires manual coding at this time. On the roadmap is a plan to provide built-in integrations with several content management systems, so please be patient!
answered
Apr 1, 2010
by
gidgreen
Please
log in
or
register
to add a comment.
+4
votes
It's actually quite easy to code the single sign-on for WordPress. Use the instructions at
http://www.question2answer.org/advanced.php
A) Ignore step 3 - use the WordPress database settings from wp-config.php in step 5.
B) In step 7, change null to to 'BIGINT UNSIGNED' (including quotes).
C) Check all is OK down to step 10. You will not have any users until you change the file at step 11:
D) Near the top of qa-external-users.php (e.g line 2 - must be after <?php ), insert:
include_once('/home/server/public_html/yoursitedirectory/wp-load.php');
Change this to match your server. This also works if you put it in the qa-config file instead.
E) About line 118, change the qa_get_login_links function to:
return array(
'login' => $relative_url_prefix.'../wp-login.php?redirect='.urlencode('question2answer/'.$redirect_back_to_url),
'register' => $relative_url_prefix.'../wp-login.php?action=register&redirect='.urlencode('question2answer/'.$redirect_back_to_url),
'logout' => $relative_url_prefix.'../wp-login.php?action=logout&redirect='.urlencode('question2answer/'.$redirect_back_to_url)
);
Make sure you change question2answer to the directory you installed Question2Answer!
F) About line 203, change qa_get_logged_in_user function to:
global $current_user;
get_currentuserinfo();
if ($current_user->ID > 0)
return array(
'userid' => $current_user->ID,
'publicusername' => $current_user->display_name,
'email' => $current_user->user_email,
'level' => ($current_user->user_level==10) ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
);
return null;
There is more scope with level if you have different user levels, but this works fine for most installs.
G) About line 297 change qa_get_user_email function to:
global $user_info;
get_userdata($userid);
return $user_info->user_email;
[Note: edited re gidgreen comment below]
H) About line 343 change qa_get_userids_from_public function:
$publictouserid=array();
if (count($publicusernames)) {
$escapedusernames=array();
foreach ($publicusernames as $publicusername)
$escapedusernames[]="'".mysql_real_escape_string($publicusername, $qa_db_connection)."'";
$results=mysql_query(
'SELECT display_name, ID FROM wp_users WHERE display_name IN ('.implode(',', $escapedusernames).')',
$qa_db_connection
);
while ($result=mysql_fetch_assoc($results))
$publictouserid[$result['display_name']]=$result['ID'];
}
return $publictouserid;
Note that you might need to change the users table name prefix in the SELECT statement (wp_ is standard - but confirm this by checking wp-config.php or your database).
I) About line 425 change qa_get_public_from_userids function to:
$useridtopublic=array();
if (count($userids)) {
$escapeduserids=array();
foreach ($userids as $userid)
$escapeduserids[]="'".mysql_real_escape_string($userid, $qa_db_connection)."'";
$results=mysql_query(
'SELECT display_name, ID FROM wp_users WHERE ID IN ('.implode(',', $escapeduserids).')',
$qa_db_connection
);
while ($result=mysql_fetch_assoc($results))
$useridtopublic[$result['ID']]=$result['display_name'];
}
return $useridtopublic;
Again, check the users table prefix in the SELECT statement.
There are other optional functions that might improve your installation, but the above will give you a working platform accessible by your current users (note that users only get listed in the Users display when they have contributed)
answered
May 28, 2010
by
shrewdies
edited
May 30, 2010
by
shrewdies
Show 16 previous comments
I did it but when i ask a question, mysql return error. someone knows how can i solve this ?
Please note that, for version 1.3, my solution will fail on the functions at steps H) and I), as these functions are now implemented slightly differently, and $qa_db_connection is not set. This leads to 3 mysql warnings, and a failure to show the user name (though the user_id is set in the database).
You should look at the examples in qa-external-users.php where you will see that the examples have a new second line [$qa_db_connection = qa_db_connection();]. Copy this line from the examples to my functions listed above, and all will be well.
Please
log in
or
register
to add a comment.