I am new to Drupal.I am working on creating custom module in drupal7.
I created one review form(contains name,rating,comments fields) in front page.
After user submit this form I stored data in database.I retrived and displayed this data in block.This is what I have done.
But I need admin interface for this module As "the user submitted rating displayed in admin section" and "admin need to perform approve,edit,delete operations on user rating".
How to implement this.
Please help me any one. Thanks in advance.
Did you search google? If so, it probably would have directed you to Creating a module configuration (settings) page
If i haven't misunderstood your question I think the proper way to achieve this is by adding your module permissions into the drupal permissions system.
You can achieve this by adding to your module the hook_permission
function custommodulename_permission() {
return array(
'custommodulename' => array(
'title' => t('custommodulename'),
'description' => t('Access URL for custommodulename module.'),
),
);
Then you can add the admin permission into admin/people/permissions page.
Not sure how are you storing the data you collect with your form but my advice is to create content type with fields your form collects. Then, when your form is submitted for storing that data you just have to create new node in your content type. You'll easy find some tutorial explaining how to create new node of some content type programmatically. That way you'll have your submitted data "in the system" so you can user i.e. views module to retrieve you data.
Related
I want to add a custom field to the Wordpress registration form without using any plugins. I want to add a dropdown menu with user-roles ( some roles I have created). Once the registration is complete the user should not have the ability to change their roles ( only admin can do that, selecting role as admin should not be allowed).
Any help will be appreciated.
I understand that you do not intend to use plugins, but you nevertheless use a theme, be it implemented by your team or some widely available theme. In any case, that theme has an implementation for your registration, so:
Find the registration form
Make sure that you find out where the registration form is.
Add a field to the form
Be it in a CMS editor or in a PHP/HTML file you must be able to edit it and add a field
Find the code which runs when a registration is posted
Again, you need to seek and find.
Enhance your functionalities which save fields
You will need to track and save the posted value
Change the database schema
You will need to do some changes on the MySQL schema in order to support the new field on database-level.
I have a site built using drupal7. The site has a registration form now. There is a new requirement now for add a couple of new fields in the registration form and put it in a new page.
ie http://example.com/register is the existing drupal registration form and user submitting this form will be registered.
http://example.com/newpage is a new page with some content and registration form in it with two extra fields. When user submits this page a new user account will be created along with saving the new fields to the user profile.
Any ideas for implementing this in drupal is appreciated.
Thanks
Does it really have to be separated? Meaning that you need in both of your registration form (normal and a custom one). If not you can just add new fields to the "normal form" in the administration of your site, going to this path:
/admin/config/people/accounts/fields
In this interface you can add custom fields (like for content types) for user's profile. You can as well choose if the field appears during regitration.
You can do this in about 15 minutes with basic understanding of the form API by creating a custom module.
What you need to look into:
Creating a module
Creating a menu hook (for your new custom page)
go to /admin/config/people/accounts/fields and create the new fields and add them to registration form
hook_form_alter - add logic in your module to check if arg(0) != your new page, and if so then hide the additional fields.
This should be enough to get you started. If this answer freaks you out then your probably in over your head. Pull up your socks or get some help.
I've installed Drupal to have a basic user registration layer. Now I need to code some PHP code in a blank page, how I can achieve this in Drupal? I need to know where I must put my PHP code.
Thanks a lot
Edit.
Basically I need Drupal only for user authorization. After a user logged into the system I want to show him a table with some data. This table was managed with JQuery.
for what you want to do I think it's not necessary a custom module, but if so, it's not so hard to do, but you can allways use some existing drupal modules mixed together to do what you want.
You will need:
Display Suite and
Login Redirect module
Basically I need Drupal only for user authorization. After a user
logged into the system I want to show him a table with some data.
For this purpose you can use Login Redirect module to redirect user to any page you want.
Now I need to code some PHP code in a blank page, how I can achieve
this in Drupal? I need to know where I must put my PHP code.
For this you can use Display Suite. Display suite or simply DS comes with a new a new Text Format: "Display Suite code". This text format allow you to add some custom code to your pages (javascript,php,etc)
you should learn to develop Drupal modules
with hook_menu you can make page
and with hook_form_alter you can edit registration form
but in drupal 7 you can manage registration fields
and also with rules and views modules, you can manage registration and user list without PHP coding
You will have to create a module in order to add php code to drupal. Try this to understand better what u need to do https://drupal.org/node/1074360
In my Drupal Site, i will be having two categories of users,say Category A and Category B. When a person wants to create an account on the site, i want to ask them which category they belong to and based on that show the fields on the User Account Form.
The fields shown depend on the category selected. The Drupal user account form has two fields by default i.e. username and email and i can add more by using the Profile module, but how to show different set of fields on the user account form depending on the users selection ?
Any help would be greatly appreciated.
Thank You
Check the Profile Setup module. Some more details about this module (from its project page):
Profile setup for Drupal 6 now works along side the pageroute module (6.x-1.x-dev) to provide additional page types via the pageroute API, so completely custom profile setup workflows are now more flexible than ever thanks to the help of the pageroute module.
Full setup instructions are given in the INSTALL.txt file in the module folder, so please READ THEM BEFORE YOU INSTALL THIS MODULE or consider submitting a bug report.
If you are upgrading from the Drupal 5 version please read the UPGRADE.txt file in the module folder.
I've done this in the past with hook_form_alter and checking $_GET['type']. If $_GET['type'] is empty, I did something like this:
$form = array(
'#value' => '<div>Register as A or Register as B</div>',
);
If $_GET['type'] is 'A' or 'B', I removed the irrelevant form elements for that type. Then in the #submit handler, I put the user in the appropriate role.
Also check out:
http://drupal.org/project/profile_role
http://drupal.org/project/autoassignrole
by using hook_form_alter you can change your form fields, using unset and add a element inside form. I assume that you have a category selection on the same user register page upon selection you can use AHAH Helper module to change form field based on category selection.
hope it helps.
So i've added several some custom profile fields (administer -> profiles) which is all fine but completely useless if I can't store the information in a database. I've been searching for hours now trying to figure out the "best practices" way for doing this with very little luck.
Do I add the new columns to the Users table? Do I create a whole new table? I even found a vague reference that the core profile module should have added those columns for me anyway? And that you should be able to use CCK in the core profile module (but I don't have any options for that)?
And then I would obviously want to allow user to update their own fields but the the custom profile fields aren't included in the $form array...
PS arrrggg! Drupal is driving me around the bend with its inconsistencies and having to hack it all the time!
If you use the core profile module, the database storage is provided automatically and you will not need to modify anything in the database. On install, the module adds two tables to the database, profile_fields to store your custom field definitions and profile_values to store the user supplied data for those fields.
The fields are automatically added to the user edit forms, via the hook_user implementation in profile_user() - the same mechanism is used to add the values of those fields to the user object when that gets loaded.
So if those fields don't show up for you, something is fishy - have you added your fields with 'categories'? If so, they won't show on the standard user edit page, but on additional new pages (one per category). These are added as menu type MENU_LOCAL_TASK, so they should create new 'tab' entries at the top of the user edit page - maybe you have a theme that does not display the tabs?
Another thing to check would be the fields visibility settings chosen on the fields configuration form. If that is set to 'hidden', the field is only accessible for administrators and module/theme code. You should at least set it to 'private' if the user is supposed to edit it himself.
As for using CCK fields, I don't think that this is possible with the core profile module (maybe some extension module provides this). A different approach is taken by the Content Profile Module. It creates a custom node type for user profiles so that the profile values are stored as standard Drupal nodes. One advantage of this is that you can use all CCK fields for profiles, as you just need to add those to the created node type.