download product after purchase the product in ubercart drupal 7


i have slove the ubercart product download after purchase Pls see :

Advertisements

Create your first simple Drupal 7 module


Create your first Drupal 7 module with the following steps.

  1. Create a folder called helloworld in sites/all/modules/custom
  2. Create a helloworld.info file
  3. Create a template file page-helloworld.tpl.php in your theme directory
  4. Enable your module at http://domain.com/admin/build/modules
  5. Visit http://domain.com/helloworld

This belongs into your helloworld.info file

; $Id$

name = helloworld

description = Reinholds Hello World module
package = Reinholds modules
core = 7.x

files[] = helloworld.module

The helloworld.module file

<?php
	function helloworld_menu(){

	  $items = array();

	  $items['helloworld'] = array(

	    'title'            => t('Hello world'),
	    'page callback'    => 'helloworld_output',

	    'access arguments' => array('access content'),
	  );

	  return $items;

	}

	/*
	* Display output
	*/
	function helloworld_output() {
	  header('Content-type: text/plain; charset=UTF-8');

	  header('Content-Disposition: inline');
	  return 'helloworld';
	}
?>

The theme template file page-helloworld.tpl.php

<?php
print $content;
?>

after login redirect other page+drupal 7


that function use in user module  function user_login_submit(

we can use condition other page

 

 

function user_login_submit($form, &$form_state) {
global $user;

if(!empty($_SESSION[‘map’]))
{
$user = user_load($form_state[‘uid’]);
$form_state[‘redirect’] = ‘mapsearch/’;
$_SESSION[‘map’]=’ ‘;
}

 

 

page.tpl

 

use condition for admin

<?php
if($node->nid==’119’)
{
if ($user->uid == 0)
{
$_SESSION[‘map’]=1;
header(‘Location: http://demo.matrixm.info/user&#8217;);

}
else
{
$user = user_load($form_state[‘uid’]);
$form_state[‘redirect’] = ‘user/’ . $user->uid;
}
user_login_finalize($form_state);
}

how to use register form in page in drupal 7


Register code use for page
if(user_is_anonymous()) {

print l(t(‘regesiter’), ‘user/register’);

}

login code for templete page

Logged in as <?php print l($user->name,’user/’.$user->uid); ?></div>

<?php if ($user->uid == 0){
print l(t(‘login’), ‘user’);

}
else{
print l(t(‘log out’), ‘user/logout’);

} ?>