In my web site i have created a custom content type Challenge which contains a list of tasks that the user has to do. I have created the custom content type from the CMS itself through admin/structure/content type. I have created a custom form, , and when the user clicks submit i have made a query which insures that the node id of that challenge and the user id is associated in a Challenge table (the code is below). It works fine. Now i need to create a view which shows the challenges accepted by the user, i.e., when the user logs in and clicks on a tab(i am using quicktab) then a view appears which shows the challenges undertaken by the user. Here my code for the query:
function my_module_menu() {
$items = array();
$items['my_module/form'] = array(
'title' => t('My form'),
'page callback' => 'my_module_form',
'access arguments' => array('access content'),
'description' => t('My form'),
'type' => MENU_CALLBACK,
);
return $items;
}
function my_module_my_form($form_state) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Accept Challenge',
'#submit' => array('my_module_action'),
);
return $form;
}
function my_module_action($form, &$form_state) {
if ($node = menu_get_object()) {
// Get the nid
$nid = $node->nid;
}
global $user;
if ( $user->uid ) {
$query = db_insert('challenges')
->fields(array(
'cid' =>$node->nid,
'uid' => $user->uid
))
->execute();
}
Well, thats it then. Now how do i create a view to show a user their accepted challenge.
Thanks