Posted by Bilmar on October 19, 2009 at 10:32am
Jump to:
| Project: | Content Profile |
| Version: | 6.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hello,
Thank you for this great module - I have been learning a lot thanks to the great drupal support base and have been able to customize a profile to the needs of the users on my website.
I was wondering if it is possible to render the user's 'account edit input box' on the content profile page?
Could someone please add any suggestions?
Thank you!
Comments
#1
subscribe
#2
Thanks for subscribing to show interest =)
To clarify - by 'account edit input boxes' I mean to be able to render the Email, Username etc on the content profile page for user to be able to edit those fields and save the changes.
Thank you
#3
Yeah, I am lookin for exactly the same functionality :)
#4
Currently I'm trying to use a rule which redirect from the node edit form to the user account edit form (which has the content profile edit tab)... The solution is not yet working, I need some time to write the correct rule :-p
#5
Subscribing. I need the same functionality. Generally speaking, is it possible to include other fields from core's user account like e.g. upload picture in the content profile content type?
#6
subscribing
#7
subscribe
#8
Here is a solution I'm using and seems to work. It's a reduced version of a custom module (it is called "usuarios", spanish word for users). It has some extra bits I think are useful for consistency and I've tried to document it as clear as possible. Hope it helps.
<?php
/**
* Implementation of hook_perm().
*
* Declare a new permission to restrict user page tabs to some users.
*/
function usuarios_perm() {
return array('view user tabs');
}
/**
* Implementation of hook_menu_alter().
*
* Declare new access control to drupal user's view and edit pages.
* it will also hide related tabs.
*/
function usuarios_menu_alter(&$items) {
$items['user/%user/view']['access callback'] = 'user_access';
$items['user/%user/view']['access arguments'] = array('view user tabs');
$items['user/%user_category/edit']['access callback'] = 'user_access';
$items['user/%user_category/edit']['access arguments'] = array('view user tabs');
}
/**
* Implementation of hook_form_alter().
*/
function usuarios_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'profile_node_form':
// If user is editing her profile, add password and mail fields.
if (!is_null($form['nid']['#value'])) {
global $user;
$form_state = array();
// Load drupal user edit form.
$form2 = user_edit_form($form_state, $form['uid']['#value'], (array)$user);
// We only want password and email.
$form['account'] = array();
$form['account']['mail'] = $form2['account']['mail'];
$form['account']['pass'] = $form2['account']['pass'];
// Automagically user fields validation is done (haven't investigated why it happens but it works :))
// So there's no need to add a custom validation callback.
//$form['#validate'][] = '_usuarios_account_form_validate';
// Attach our own submit callback to handle extra fields.
$form['#submit'][] = '_usuarios_account_form_submit';
}
break;
}
}
/**
* Custom submit callback function. We need to save drupal user fields.
*/
function _usuarios_account_form_submit($form, $form_state) {
global $user;
$edit = array(
'pass' => $form_state['values']['pass'],
'mail' => $form_state['values']['mail'],
);
user_save($user, $edit);
}
?>
#9
Another approach is done in content_profile_registration. I think it can be also used for the use case exposed in this issue.
#10
Code from #8 works very well with content profle 1.0, thanks jonhattan!