0

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.'

1
  • Take a look at the survey plugin's code, find where the submitter_id is generated and reverse that in your own plugin. Commented May 27, 2012 at 19:35

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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