I have been running into a brick wall trying to do this for about a week now. Can't find any guidance.
We have a community being powered by drupal that is based around a desktop application. The desktop application is able to create the community user during registration by automatically filling in the form using the user's registration information for the application.
Our management does not want any members in the community that are not using the desktop software. I have created a custom login block, and changed the links to "user/register" everywhere in the modules we are using, except on the actual "User account" page that offers "Create a new account", "Log in", and "Request new password" on the tabs.
I have found the code in user.module that creates these tabs, but I cannot seem to hide the link for "Create a new account":
<?php
$items[] = array('path' => 'user/register', 'title' => t('Create a new account'),
'callback' => 'drupal_get_form', 'callback arguments' => array('user_register'), 'access' => !$user->uid && variable_get('user_register', 1), 'type' => MENU_LOCAL_TASK);
?>
(php tags are for decoration only)
I understand all the arguments on how to do this the right way, by building a custom module to take over the page etc. But the desktop app is already coded to use the url "domain.com/user/register" for automatically filling out the form, I realize that users could potentially find this link, but we need to hide the link from those who click "Request new password" and, also hide it from bots that ignore the robots.txt file that we are using.
To sum up, is there anyway we can assign a custom class, or hide the tab completely from users, but still have the form appear when a user manually enters the url "user/register"?
Thanks in advance!
Comments
I think I have a working fix...
In my template.php (in the theme we are using) I added the following function (found on another site) above the function _phptempate_variables($hook, $vars):
(php tags for decoration only)
Then, inside of the function _phptemplate_variables($hook, $vars) I added this (again php tags for decoration only):
Seems to have done the trick. The tab is no longer being generated, but I can access the form by manually going to domain.com/user/register
Hope this helps others.
---
"If you are thinking, you are winning. Resistance is victory"
woohoo! thank you for this!
woohoo! thank you! you just saved me several more days of trying to figure out how the hell to suppress that tab. but in my case, inside the function _phptemplate_variables($hook, $vars) I added this instead of your code above. (php tags for decoration only):
so, again, thank you so very much! :)
sarah azurin
php developer | drupal developer | book worm
linux registered user #318168
thanks for posting
I added the call to removetab from the template.php page ... function phptemplate_preprocess_page(&$vars)
works great.
It is useful when you do want visitors to be able to create accounts, but not from the login page.
Thanks for posting this nugget.
Technical Architect : Philadelphia, PA
Brilliant! Perfect for if you
Brilliant!
Perfect for if you want user to create their own account, but don't want the link to register page shown in the login page.
Cheers!
P.s. I thought it wasn't working... but then I remembered that the page was cached...
Exactly!! what I want - but, but ...
your solution:
"In my template.php (in the theme we are using) I added the following function (found on another site) above the function _phptempate_variables($hook, $vars): ..."
--------------------
But I'm using Salamander Theme. There is no such thing as: function _phptempate_variables($hook, $vars):"
Do you know any way to replicate what you did in Salamanders template.php? There is not much code in it anyway.
Thanks! Håkan
Does this work for Drupal 6?
I tried this for d6 using the function themename_preprocess(&$vars, $hook) function but it did not work. I looked in api.drupal.org but couldn't decide or tell which function could take the phptemplate_variables place.... We don't have that in D6. What could I substitute?
I need it for drupal 7.
How to fix it for drupal 7.
I have researched for a whole one day, and did not found any solutions. Because I am not finding any corrosponding function to the the themename_preprocess in the template.php of my theme. Because in d7 the functions are different.
I tried putting the code in different functions in the template.php like "themename_preprocess_page(). themename_preprocess_html". But the $var['tabs'] was very different, it was not a stirng at all in the template.php of the my theme in d7.
There is no d7 release for the tab tamer module either.
Any or all solutions will be a great help for me.
TIA,
Pradeep.
This is the answer only if
This is the answer only if you want anonymouse users not to create account on your site. D7 has the option to disable user registration for anonymouse users.
Navigate to : Home » Administration » Configuration » People » Account settings
under "REGISTRATION AND CANCELLATION" tab you can set who can create account on your site.
Thanks
-Manish
Followed a different way of doing this
Hi
I am having the same issue, unfortunately the steps given did not work for me. I am using drupal7.
I tried it using the following method and it works for me. Hope it would help someone facing the same issue.
I went to template.php of my theme file that I am using. Example : sites/all/themes/test/template.php.
In function test_process_page(&$variables), I have added following three lines to remove it.
unset($variables['tabs']['#primary'][0]['#theme']);
unset($variables['tabs']['#primary'][1]['#theme']);
unset($variables['tabs']['#primary'][2]['#theme']);
Now it is working fine at my end.
Thanks
Jyotisankar
Jyotisankar Pradhan
or simply...
for those who end up at this page and want an approach through normal settings, look at:
http://drupal.org/node/182215
http://drupal.org/node/289388
But...I believe those
But...I believe those approaches completely disable account creation, not just getting rid of the link as the OP seems to have wanted.
Another way
is a quick fix, to use string over rides module. Enter 'create new account' as the string to over ride, then enter nothing in the text to replace it. This still leaves you with the grey shadow of the tab, but not the text, and you could probably remove the image via CSS.
HTP (for other non coding types!)
Renaee.
String Overrides only half works
I tried using String Overrides module as suggested by Renaee
However, I found that it removed the text from the 'create new account' button at the end of the registration form as well as from the tab!
@beckjohnson: Did you find a D6 solution for the original method?
Thanks
theme_menu_item_link
In D6, the following snippet added to your template.php file will cause the tab and link not to render. At the same time leaving other instances of the 'Create new account' string untouched.
THANK YOU!
THANK YOU, THANK YOU, THANK YOU, THANK YOU!
Seriously, this helped me a lot - THANK YOU! Drupal is so powerful, but man it's got such a steep learning curve!
D7 fix
Sadly this code doesn't seem to work for Drupal 7. Any tips for you you might tweak this to work for D7?
http://drupal.org/node/232702
http://drupal.org/node/232702#comment-5483392
Tab Styles
This worked great for removing the menu item, but is there any reason why this would mess with tab styles? They look broken now for all tabs across the site. Using Zen and CTI Flex.
Thank you!
this works for me too. Thank
this works for me too. Thank
TabTamer Module
works well to remove these links.
Roxy
In D7 it just barely works.
But, as of date of posting the .module code needs to be hacked at line 309.