URL to "Edit usernode"

Grooviak - August 2, 2007 - 19:34
Project:Usernode
Version:5.x-1.2
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Is there a direct URL to edit the users own usernode? It would be very helpful if there could be added a link like usernode/edit to reach the nodes edit page. If it's not possible, it would be a very nice feature.

#1

Owen Barton - August 27, 2007 - 22:39

You can do this easily in a custom module by adding a menu item in hook_menu like:

<?php
 
global $user;

 
$items = array();
 
$admin_access = user_access('administer users');

 
// Control logic from user module 
 
if (!$may_cache) {
    if (
arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
     
$account = user_load(array('uid' => arg(1)));

       
// This adds a menu item to edit the usernode
       
$items[] = array('path' => 'user/'. arg(1) .'/profile', 'title' => t('Edit profile'),
         
'callback' => 'drupal_get_form', 'callback arguments' => array(USERNODE_CONTENT_TYPE .'_node_form', usernode_get_node($account)),
         
'access' => $admin_access || $user->uid == arg(1), 'type' => MENU_LOCAL_TASK, 'weight' => -5);
    }
  }
?>

While we could add this to usernode module I am not sure if many people are using it in this way...

#2

fago - September 8, 2007 - 21:19

thanks grugnog for sharing - I leave this open so that it's visible for others.

 
 

Drupal is a registered trademark of Dries Buytaert.