Insert value to database on signup
-
Hi Roland,
This question is a follow up from this thread.
How do you insert information a user enters on a signup form to the database when the submit button is pressed?
In the thread linked above you helped me creating a custom dropdown field and now im struggling arround to get that selected value back to the database as soon as the submit button is pressed.
At the moment I have this code for my custom dropdown:
<?php global $wpdb; $field = 'activity_title'; $activities = array(); // grab the unique stored values from the field $result = $wpdb->get_results('SELECT DISTINCT p.' . $field . ' from ' . Participants_Db::$participants_table . ' p WHERE p.' . $field . ' <> "" AND p.approved ="yes"', ARRAY_N); // now we convert the query result into a simple array foreach($result as $value) { $activities[] = current($value); } // print the dropdown echo PDb_FormElement::get_element(array( 'name' => 'selected_activity', 'type' => 'dropdown', 'options' => $activities ) ); ?>To get the information from the selected dropdown value back to the database I was starting to use code like this:
$table_name = Participants_Db::$participants_table; $wpdb->insert($table_name, array('activity_title' => $_POST['selected_activity']));Can you help me that the selected value from the dropdown is inserted to the database when the submit button is pressed?
Thanks and regards,
Mario
The topic ‘Insert value to database on signup’ is closed to new replies.