frankyonnetti
7/7/2013 - 8:51 PM

#drupal 7 create edit link based on user role or profile role

Drupal 7 - create edit link based on user role or profile role #drupal #d7

<?php
    // get user id from menu object
	$account = menu_get_object('user');
	$userid = $account->uid;
	
	// check if user can edit user_profile by user_role
	global $user;
	$check = array_intersect(array('administrator', 'SoshoAdmin'), array_values($user->roles));
	
	// print link for admin or owner of profile
	if (empty($check) ? FALSE : TRUE) {
		print l('Edit Profile', 'user/' . $userid . '/edit');
	} else if($user->uid == $userid) {
		print l('Edit Profile', 'user/' . $userid . '/edit');
	}
?>