[support] including profile edit form on a page...
Christopher M. Jones
cjones at partialflow.com
Fri Sep 3 20:41:40 UTC 2010
Maybe someone else has an idea why the code itself doesn't work. But if
you'll pardon my presumption, I'm not sure there's ever a situation
where you should be putting code like this in page.tpl.php. Maybe with
more information someone could suggest an alternative, more "best
practice" method for achieving your desired result.
For example: if I want to arbitrarily place form content on some page of
my choice, I'd use panels.
And failing that-- if you really can't find a tool like panels that does
what you want, then write a custom module to do it. For example:
mymodule.module:
mymodule_menu(){
$items = array();
$item['my/custom/page'] = array(
'title' => t('Title of my page'),
'page callback' => 'drupal_get_form',
'page arguments' => 'user_profile_form',
'access arguments => array('permission the user has to have'),
...
);
return $items;
}
This code, once the module is enabled and all the cache is cleared,
should put the form you want on the path you just named. If you want it
in a block, then decalare block content in your module instead of a menu
entry, and place the block into a region.
On 09/03/2010 04:16 PM, Kevin Davison wrote:
> The following PHP is what I have in a page.tpl.php, and it worked before
> I upgraded Drupal 6.14 to 6.19 and enabled clean URLs (with Pathauto).
>
> Now when I submit a profile edit, the page just reloads quickly, but
> nothing is written to the database. Anyone know why? Need more info? Thanks!
>
> <?php
>
> global $user;
> // if the user is logged in
> if ($user->uid > 0) {
> module_load_include('inc', 'user', 'user.pages');
> profile_load_profile($user);
> print(drupal_get_form('user_profile_form', $user, 'Personal
> Information'));
> }
> else {
> // do something else
> }
>
> ?>
>
> OLD CODE...
>
> <?php /*
> global $user;
> $uid = $user->uid;
> if ($uid > 0) {
> include_once drupal_get_path('module', 'user') . '/user.pages.inc';
> // print(drupal_get_form('user_profile_form', $user));
> profile_load_profile($user);
> // var_dump($user);
> print(drupal_get_form('user_profile_form', $user, 'Personal Information'));
> }
> */
> ?>
>
More information about the support
mailing list