How to redirect User after registration in opencart 2.0.3.1? - opencart2.x

My registration page URL like: www.exmpl.com/index.php?route=account/register when I submit after filled all fields then it redirect me to login page but I want to redirect it to thank you page.How can I do this?

This function (in /catalog/controller/account/register.php) is responsible for redirection ($this->response->redirect($this->url->link('account/success'));, to be more precise). Just need to check which page is "thank you" page (I'm not sure right now).
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'], $this->request->post['password']);
unset($this->session->data['guest']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
$this->response->redirect($this->url->link('account/success'));
}

Related

Yii2 CRUD and Pagination

I am using Yii2 with Pjax for index/gridview listing. using pjax pagination , search all working fine without postback to server.
My problem starts now,
suppose i am on page number 2, i have clicked on edit record of that 2nd page list, i reach to update view, i have done changes and saved, now i am redirected to view , now i clicked on index link from breadcrumbs.
i want to reach to page number 2 of index rather then 1st page.
Traditional process for this is get refereeing page params an append that in breadcrumbs.
But is there any simple approach to this problem where i can write few lines of code and its applied to every where in backend?
Thanks for reading.
For remembering grid filter, pages i use yii2-grid-view-state
If you need to store page only, isn't it quite easy to pass page param into your view url (<model/view>) like <model>/view?id=<id>&page=<page>?
in your index.php view, edit your ActionColumn as follow:
[
'class' => 'yii\grid\ActionColumn',
'urlCreator' => function ($action, $model, $key, $index) {
return \yii\helpers\Url::to([$action, 'id' => $model->id, 'page' => Yii::$app->request->getQueryParam('page', null)]);
},
],
As you can see, I'm getting page param from request url and pass it to models' action buttons (to all buttons, but in your question it would be enough for view button of course)
And when you click to view model, in our Controller we need to get that page value and pass it to our view.php view (in order to place it in breadcrumbs).
Our ModelController:
public function actionView($id, $page = null)
{
return $this->render('view', [
'model' => $this->findModel($id),
'page' => $page,
]);
}
And finally view.php view will get the page value, and populate the index url (if not null):
/* #var $page int */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Index', 'url' => ['index', 'page' => $page]];
So when you press the Index breadcrumb, it will open the page, where you entered from.
Some advantages againts session implementation (#user1764431 solution):
Each of your tab can return to it's own last page
Simple and stupid solution
Some disadvantages:
If you need to store some filter params, url could stretch very long
Just add following Code in every controller of actionIndex() rest all things will take care
$searchModel = new CentervideosSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
/*Code insertion block begin*/
$params = Yii::$app->request->queryParams;
if (count($params) <= 1)
{
$params = Yii::$app->session['customerparams'];
if(isset(Yii::$app->session['customerparams']['page']))
$_GET['page'] = Yii::$app->session['customerparams']['page'];
if(isset(Yii::$app->session['customerparams']['per-page']))
$_GET['per-page'] = Yii::$app->session['customerparams']['per-page'];
}
else
{
Yii::$app->session['customerparams'] = $params;
}
$dataProvider = $searchModel->search($params);
/*Code insertion block Ends*/

htaccess user profile folder

On my website there is a user profile file, which is in php. Where if you write http://www.youdomain.com/user.php?id=[user id]. It shows that users profile with the id.
Is there a way in htaccess that if a write http://www.youdomain.com/users/[user id] it will display the page http://www.youdomain.com?id=[user id].
Thank you.
$('.Nav a').each(function(e) {
var href = e.attr("href");
if (href === window.location.href) {
alert(href);
}
});

drupal6 submit to third part site with internal redirect

I'm trying to submit a drupal 6 form PIA to a third party site for processesing, but after submitting the form, I need to redirect to a thank you page within my own site.
I've read this post - Drupal form submission to a 3rd party website
but i'm nor sure how to set up the redirect properly.
this is my code:
$form_state['#action'] = 'external site.com';
$form['#redirect'] = 'thankyou.com';
thanks
Make sure the redirect is the last step. Something like this:
function my_module_form {
$form['#action'] = 'some.external.site';
# Store the redirect in a value element, maybe we need some data
# which are passed to the form, like a user ID, node ID etc.
# So lets store the link in a value element
$form['redirect_link'] = array(
'#type' => 'value',
'#value' => url('some.redirect.page'),
);
}
function my_module_form_validate ($form, &$form_state) {
# Do some validation stuff...
}
function my_module_form_submit($form, &$form_state) {
# show some confirmation message...
drupal_set_message(t('Successfully sent your data into space.'));
# And finally the redirect...
# The 'redirect_link' value was passed internally, without being sent
# to the browser so we can safely use it.
$form_state['redirect'] = $form_state['values']['redirect_link']
}
Redirect property is also set in $form_state.
$form_state['redirect'] = 'some.com';
Since I'm only trying to send informtaion to a third party and not actually redirecting the page after form submission to a third party site.
I got the right answers tot he wrong question.
This is what I ended up using that worked for me:
$url = 'http://thirdpartyurl';
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$data = drupal_query_string_encode($pass_the_form_info);
drupal_http_request($url, $headers, 'POST', $data);

how do i make diffrent registration form in drupal?

Is there a module that can make different registration forms for different roles during sign up? (ex. each Editor,Main User,Sub User role have different form)
Here's what you should do
start with install profile2-7.x-1.2.tar.gz.
entity-7.x-1.0-rc3.tar.gz once you have profile2 installed -->
enable --> click on configure - (Here you see your profile types
-add as many as you want).
when you add a new one or modify the existing one "Main" make sure you check "Provide a separate page for editing profiles."
4. Now to have different registration, login and password change pages
install and enable profile2_regpath-7.x-1.9.tar.gz
Now visit the profile Types Page again here you should see "UNIQUE REGISTRATION PATH" .. rest is easy ..
There is :)
http://drupal.org/project/autoassignrole
to assign by path you will also need Content Profile:
http://drupal.org/project/content_profile
check out this tutorial on how to pull it off:
http://www.web-a-team.com/blog-post/user-registration-more-one-role
Here is some idea how to solve your question in drupal 7(I think it should work in drupal 6 also). However its not safe since anyone can just change the role they have:
function my_module_form_user_register_form_alter(&$form, &$form_state, $form_id) {
$company_role = $form_state['build_info']['args'][0];
$form['account']['company_role'] = array(
'#type' => 'select',
'#title' => t('Company role'),
'#options' => drupal_map_assoc(array('editor','main user','Sub User')),
'#description' => t('Please select your company role'),
"#empty_option" =>t('- Select -'),
'#weight' => -11, // Add the select box above username that have weight -10
);
switch (strtolower($company_role)) {
case 'editor':
// add extra fields for editor
$form['account']['company_role']['#default_value'] = $company_role;
break;
case 'main user':
// add extra fields for main
$form['account']['company_role']['#default_value'] = $company_role;
case 'sub user';
// add extra fields for 'Sub User'
$form['account']['company_role']['#default_value'] = $company_role;
break;
default:
$form['account']['company_role']['#empty_option'] = t('- Select -');
$company_role = null;// error handling or default case
}
}
If you for example have LDAP in your company you could instead get this information from LDAP(https://www.drupal.org/node/1053748). Then you can be more sure about the role is chosen correctly.

use drupal hook_nodeapi

i have a page tweety which contains a single form where a user enters a word in a textbox and in on pressing search the tweets corresponding to that word are displayed.
I want to use hook_nodeapi to add these tweets but i want those things only on a specific url not all the page(or any node type).
I ll use hook_menu to make that page and display the form for the search. What should i do after that. I knw the twiiter api to fetch the tweets so that is not a issue.
I think what you're attempting to do is have the tweets load on a predetermined page by passing the posted information to the page, is that correct?
There's a couple ways I think you could accomplish this - easiest, and not requiring any complex ahah scripting would be to take the word they enter and generate a path which you could then use to make the page in question.
Make a menu Item:
function mymodule_menu() {
$items = array();
$items['mymodule/tweets/%'] = array(
'title' => t('Tweets about' . check_plain(array(2))),
'page callback' => 'mymodule_tweet_display',
'page arguments' => array(2) // This is the 3rd argument in the path, the %
);
}
In your form, you'll need to send the user to this path so add to your hook_submit function:
$tweet_topic = $form_state['values']['your-field-name-here'];
drupal_goto('mymodule/tweets/' . $tweet_topic);
Now add your page module, this is where you can use the twitter api:
function mymodule_tweet_display($tweet_topic) {
$tweet_topic = check_plain($tweet_topic);
// Use this variable in your Twitter API call
// ...
// Make sure you assign your display content to the page by returning a variable
return $page;
}

Resources