How create a views showing sponsored user profile field - drupal

I created a profile field called Sponsor name, who sponsor or introduce him into the website. The sponsor must be a user in the website. A user can sponsor any number of users to the website. When a user wants to register, he must give the sponsor name. I have done it successfully.
Now I want to create a view showing a list of sponsored users corresponding to each user.
for example:
User James sponsor's
Williams
Perter
John
User Williams sponsor's
Adam
Jimmy
Thanks in advance.

If you want a single page per user, then what you would want to do is to add an argument to your view. Where the argument would be the field you created for the sponsors name, and then in the settings for that argument, you would get the user id or username from the URL.

Related

How to Sync CPT Data oder BG Group Meta with User/member

i have big Challenge and i want to know, if it’s possible.
I need a Solution to create Company Profiles with Fields about the Adress, ZipCode, City etc… This Company can create a user (employee).
This User can invite another User(employee) to this Company.
If he do that, the Company profile Fields must be Synced with the Employee Profile Field Data.
The Employee Fild Data about the Company must be the Same as tthe Company.
My Acutally Setup:
User Creation: BuddyPress
Company Profiles: With BuddyPress Groups
To create a Group (Company) and a User Registration i use Buddyforms.
Buddyforms Create a new Post in a Custom Post Type with the Company Information an attach this Post to the Group.
Maybe is it possible, all BP Group Members will be synced with this custom fields?
Or maybe i need another Solution?
Regards

Drupal how to have certain admins only see the users they've created

I use Drupal 7 and would prefer to do so but if I need to use Drupal 6 I will. I have a Drupal 7 site that I allow "advisors" to create authenticated users. I am an admin on the site so I see and can do everything. All that an "advisor" can do is create and edit authenticated users. Is there a way to make a view that displays the users that the particular advisor has created while the advisor is logged in?
If you don't understand what I'm saying let me put it this way. I am the admin of the site so I can do everything. I created a user role called advisor. There's also an authenticated role for users. Advisors can create authenticated users. So I have Advisor 1. Advisor 1 created 10 users. I also have Advisor 2. Advisor 2 created 3 users. I'd like a page (more than likely built with views - and I've used views before on other sites so I'm familiar with them) - I'd like a page that Advisor 1 could go to once logged in and it would display all of the 10 users that they created. Advisor 1 wouldn't see the users that Advisor 2 create.
Is this possible? Any help on this would be greatly appreciated. Thank you in advance.
I have implemented something similar and I can give you some guidelines.
First of all drupal 7 doesn't store the information of the creator of the users.
So, in order to track this you will need to attach a custom field to the user to keep this information.
In such case you ll have to make sure that every creator can insert only himself in this field and not anyone else or you 'll have to find an automated way to fill it in.
I suggest you use field permission module for setting permissions to this field (users probably should not even have view, creators should not be able to change it etc ) and computed field module for automatically populate the field (eg creator_field) upon creation for example with the uid of the creator.
Finally when creating the view you could add contextual filtering by using the logged in user on the creator_field.
You should also have a look at Organic Groups. I haven't use it but might be helpful
Hope it helps.
Updated
Add
global $user;
$entity_field[0]['value'] = $user -> uid;
to the Computed Code (PHP) in the computed field settings and store the value as integer in "Database store settings". Then in your view you should add a view of user with contextual filter of creator_field. In the contextual filter settings you must set "provide default value" -> "User ID from logged in user" in the "WHEN THE FILTER VALUE IS NOT IN THE URL" section.
This could be done relatively easily in Drupal 7 by adding a field to the user profile that points back to the user creator (using the Entity Reference module). Profile2 could offer a shortcut to making this field available on a profile, though if this is the only customization that you need to add to your profiles, it would be cleaner to do this in a custom module.
A view (Views module) could be configured to output a list of users with the current logged in user as the creator.
You'll also need to add similar logic for user_access to allow/restrict profile editing (if the current user is the user referenced in the profile). A permissions hook also could be useful if you plan to have different admin levels.
The Tokens module should work to insert this value for the new user, by inserting the current user into the field. Or you can do this before the user is saved. It would go a little something like this:
function mymodule_user_presave(&$edit, $account, $category) {
if ($account->is_new) {
global $user;
$created_by = $user->uid;
$edit['created_by'] = $created_by;
}
}
Good luck.

Drupal 7: Generating HTML e-mail depending on chosen term and node

I want to make ability for anonymous users to get e-mail with discount coupon for manually chosen product.
It could be put in one form (select lists) or multiple steps (product selection > user info)
How it should work:
User in page/block chooses taxonomy term (category of product)
User chooses node (filtered by chosen taxonomy term)
User inputs name, e-mail.
User clicks submit button
Html e-mail is being generated and sent with user name, chosen node title and custom field from that node with discount rate.
Is it difficult to achieve it work?
Thank you for your help.
What you're looking for can be recreated with the Webform module (https://drupal.org/project/webform), Simply create a webform with your desired fields (category, node, name, email) and then customize the receipt to use the [node:discount-code] token for the user's chosen node.

Drupal Views Content Profile User as an argument

I have a normal Drupal User. I have used the content_profile module to create a profile content type. This content type contains a node reference to another content type company. The company node then references a type of node called Task.
I want to create a view that list all the tasks for a given user id.
So I imagine I would create a view with an argument of user id. Then I would add the relationship to the profile and the company and output the Task title.
The user id used seems to work on the created used ID and not the user id of the content profile that it is referencing. In our system the "admin" user creates the profiles so it causing some problems.
Any ideas? I feel I may need to write a custom module to do what I want.
i have answered a similar question in the past about how to create a view using part of the url as an argument to filter the view by the user profile. check out this url. the answer you are looking for may be a variation of my original response.
also, how are you creating those profiles? on one of my sites, when i created the profile page, its author ID is automatically changed to the user it is associated with.

Give a user rights to a specific node in Drupal

I'd like the user "student" to be assigned to a content type "Projectgroup". I can do this by adding a user reference to the Projectgroup content type form.
Example:
Projectgroup = Beta testers
Students (user referenced) = Kim, Joel, John.
When Kim logs in, she should only be able to post as "Beta testers".
How can i make sure when the user logs in he/she can only post with the correct projectgroup rights?
You want to assign roles to these students and then control what permissions are available to that role.
http://drupal.org/handbook/modules/user

Resources