new membership and account creation process : modal and form is in a separated page
This commit is contained in:
55
materio_user.pages.inc
Normal file
55
materio_user.pages.inc
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
function materio_user_register(){
|
||||
$return = array();
|
||||
|
||||
// $return['block'] = '<h3>'. t('create your materiO\' account') . '</h3>';
|
||||
// $return['block'] .= drupal_render(drupal_get_form('user_register_form'));
|
||||
|
||||
// $block = module_invoke('materio_user', 'block_view', 'user_register');
|
||||
// $return['block'] = render($block);
|
||||
|
||||
$block = block_load('materio_user','user_register');
|
||||
|
||||
$return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
|
||||
|
||||
// dsm($block, '$block');
|
||||
drupal_json_output($return);
|
||||
// return 'hello';
|
||||
}
|
||||
|
||||
function materio_user_register_submit(){
|
||||
$return = array();
|
||||
$return['POST'] = $_POST;
|
||||
|
||||
$form_state = array( "values"=>$_POST);
|
||||
drupal_form_submit($_POST['form_id'], $form_state);
|
||||
|
||||
$return['form_state'] = $form_state;
|
||||
|
||||
$return['errors'] = form_get_errors();
|
||||
if($return['errors'])
|
||||
unset ($_SESSION['messages']['error']);
|
||||
|
||||
// after registration user is automaticly logged in, thank's to login tobogan module
|
||||
|
||||
drupal_json_output($return);
|
||||
}
|
||||
|
||||
function materio_user_login_submit(){
|
||||
$return = array();
|
||||
$return['POST'] = $_POST;
|
||||
|
||||
$form_state = array("values"=>$_POST);
|
||||
drupal_form_submit($_POST['form_id'], $form_state);
|
||||
|
||||
$return['errors'] = form_get_errors();
|
||||
if($return['errors'])
|
||||
unset ($_SESSION['messages']['error']);
|
||||
|
||||
// if user-login form succed we retreive the user uid on $form_state, then we can effectively loggin the user
|
||||
if($uid = $form_state['uid'])
|
||||
user_login_submit(array(), $form_state);
|
||||
|
||||
drupal_json_output($return);
|
||||
}
|
||||
Reference in New Issue
Block a user