Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to display a table of results for particular users who have submitted answers to quizzes. The problem is that the mysql database I am working with has a funky value for the user's ID.

I'm working off of the plugin WP Simple Survey, which allows the admin to create a number of surveys and weight answers with "points." The only data table that has a unique value for the user's id is "submitter_id," but the format is not the regular WP user id expressed as a number. Instead it looks like this:

wpss_4fc2636f6814a

I need a way to translate this to a typical user_id or user_login in the wp_users table so I can make a plugin that will display users' total scores.

UPDATE: From the suggestion below, it appears the submitter_id is being created by the uniqid function in PHP. Apparently, it's a unique string that reflects the current time.

So... the only thing to do now (I think) is to create a variable based on a mysql query that will retrieve the current logged in user's id and set that to the 'submitter_id.'

share|improve this question
    
Take a look at the survey plugin's code, find where the submitter_id is generated and reverse that in your own plugin. –  Johannes Pille May 27 '12 at 19:35

1 Answer 1

up vote 1 down vote accepted

The plugin now works as I would like, with a little alteration. Instead of setting submitter_id to a random value, it is now set to the logged in user's id. This will allow displaying other users' answers. The + indicates new lines of code in the output_quiz.php file:

function wpss_getQuiz($quiz_id){
  global $wpdb;    
 + global $current_user; get_currentuserinfo();

<input type="hidden" name="quiz_id" value="'.$quiz['id'].'" />  
      +  <input type="hidden" name="submitter_id" value="'.$current_user->ID.'" />';

Thanks to Johannes Pille for the suggestion.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.