removing create new account tab from login page in drupal 7 - drupal

Drupal login page, while going from url ?q=user shows you login form and it also shows Change password and Create new account tabs .
I want to remove the Create new account option/tab from there and also I do not want user to access registration page even via url: ?q=user/register.
Anyone?

To hide the Create new account tab in the /user path, you can insert the following in your module code:
function modulename_menu_alter(&$item) {
// Hide the "Create new account" tab
$item['user/register']['type'] = MENU_CALLBACK;
}
This hides the tab but still allows for /user/register to be accessed.

Open the Configuration admin menu, and under the People heading click Account Settings. Under the heading Who can register accounts? select Administrators only and then save the settings.

The Tab Tamer module will do this. Just make sure you choose hidden and not disabled, otherwise users will get access denied errors.

Home>administration>configuration>people> who can register accounts> select administrators only

To remove the "Register Tab" in login page for visitors, go to Administration>>Account Settings>> select the administrator to create the account. Save the changes. By doing this, only "Admin" can create the accounts. Users cannot see the "Register" Tab.

Related

gvNix: How to restrict access based on roles

I'm developing an application using gvNix. I used typicalsecurity addon to secure my application. What I need now is to allow the user to update only their profile. i.e. the user can see a profile tab on the nav bar menu, and when clicking on it, a form should be displayed containing only their data.
I tried adding the following to my code, but it restricts the access even to the admin.
#RooWebScaffold(path = "users", formBackingObject = User.class, delete=false, create=false);
The xml here removes the menu tab or part of its sub items, so it doesn't show an option to edit the profile
...
xmlns:sec="http://www.springframework.org/security/tags"
...
<sec:authorize ifAllGranted="ROLE_ADMIN">...</sec:authorize>
Usually all the users should update their profiles, so the link should be visible for all users.
Then modify the controller method that handles that request to get the user principal for the requester, this is the way to load the profile of the loged user.
To get the principal of the user read the Spring Security docs.

How to create secured page that limits access to users with the correct permissions?

For a Drupal 7 site, I need to create a secured page with a list (view) of documents(.pdf's). There will be one page with a list of documents (a view of pdf's). To get to that page and be able to download any of the .pdf's, the user must be logged in with their own unique username/password. So what I believe needs to be done is the following.
Set up a page with a view of the documents (can do).
Make sure the docs (pdf's) can't be viewed with a direct URL (I think private file)
Prevent access to the page by non-logged in users. (no idea. help!)
Create a menu item for the page that only displays when the user is logged in. (no idea. help!)
Define permissions for accessing the page and add the permissions to specific roles. (I think I can do)
Can anyone provide info on how to do this? Is there a module for this functionality?
thank you,
You can use content_access module to do this. You will be able to restrict access to any content (you list page) by role.
If you create a link to this page in the main/secondary nav (for example) then this link should only appear to a user that has the appropriate permissions (as defined in the role).
LF
create some permissions and assign that to particular user then in your hook_meny you can use user_acccess function to check that whether the logged in user has that permisiion or not and according to that return true or false.
if(user_access(YOUR_PERMISSION_HERE)) {
return TRUE;
}
else {
return FALSE
}
You can also write your sql query inside that. You can put this code in your function and call that function in your access callback for that particular form menu definition

Force anonymous to register before submitting a form. Drupal 7

I want to force anonymous to register an account before submitting the form.
So I have to allow permission for anonymous to access the form,
Then I use hook_form_FORM_ID_alter to edit form. Then I wanted to redirect submit button to another link if it is clicked by anonymous.(I still have no idea how to do it. It would be nice if anyone can tell me)
Is this the right solution?
For now,
I have a pop-up a login form (Modal forms and Facebook OAuth). In the form there is a register button. Then If user choose to register I want to keep the form that he have already input and show it after he confirm his email.
Thank you.
Off the top of my head, I would allow the form to be submitted either by an anonymous user or a registered one.
in my function MYMODULE_MYFORM_submit() I would check to see if the user is logged in.
If yes proceed as normal, if no, store the form, either in a temp SESSION variable or into a custom MySQL table and forward the user to login/register page (mysite.com/user) using drupal_goto('user')
once the user was registered you could then check for the existence of the form in the SESSION array or your MySQL table, and then carry on with the process as you would if the user had been logged in in the first place
Hope this makes sense or is of help

Remember login from WordPress password protected page

I know how to password protect a page and check if it has been entered with post_password_required. What I need to know is if I can then continue to know if a user has logged into this password protected page even after leaving it. The reason for this is because I would like to display a site wide navigational sidebar that allows the user to get back to that page, but only have it show if they have logged into that page earlier.
Set a session variable if they login successively to the given page, then when they are on another page later, have the sidebar echo the link if that session var is set.
The value of the session var can be the url to create the link, if you have more than one page you're trying to do this with.

Drupal: customizing user register form

I want to customize the user/register form.
When the anonymous user goes on this page I don't want to show the tabs Create new account, Log in, Request new password, and don't want to see the fieldset Account information with a username and email.
How can I do it in Drupal 6?
The tabtamer module lets you control what tabs are visible from the admin pages.
I'm not sure if it's possible to remove the user profile page entirely, but a module like login_destination or logintoboggan let you control where the user goes when they log in.

Resources