Ok so I was able to create the sub menu page but I'm unable to get the form to be displayed on the sub menu page? What would be the problem? Here is the code I'm using below. Thanks!
$submenuone = add_submenu_page(UR_FILE, 'Add New User', __('Add New User', UR_NAME), 'ur_create_form', 'ur_create_user', array($this, 'render_ur_user'));
function render_ur_user() {
if (!current_user_can('ur_create_user')) {
wp_die(__('Access denied.', UR_NAME));
}
$add_user .= $this->add_wrap(__('Add USER', UR_NAME), "<br>"--"</br>);
$add_user .= "<form id='ur-user-form'>
";
$add_user .= "<p><input type='text' id='user-name' name='user-name' value='' /> ";
$add_user .= $this->add_wrap(__('Add User', UR_NAME), "<button class='add btn-cone'>", "</button></p>");
$add_user .= "</form>
";
}
Now for the query
function db_insert_new_user($input) {
global $wpdb;
$result = $wpdb->insert($wpdb->prefix . UR_USERTBL,
array('name' => $input->name,
'surname' => $input->surname
),
array('%s'),
array('%s')
);
if ($this->return_result($result)){
$input->user_id = $wpdb->insert_id;
$this->renderuser($input);
}
}
function renderuser($input){
$output = array(
'user_id' => $input->user_id,
'name' => $input->name,
'surname' => $input->surname
);
$this->render_json($output);
}
Can anyone tell me, why isn't my form being displayed on the sub menu page? (ALSO) Once I do get it working, how to do I submit these values to the database(mySql)? Thanks!