News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[TIP/TRICK] Remove register button

Started by Ninja ZX-10RR, June 10, 2014, 01:36:14 PM

Previous topic - Next topic

Ninja ZX-10RR

Question: How can I remove the registration button and prevent user from registering?



Open /Sources/Subs.php and find:
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],


Replace with:
'href' => $scripturl . '?action=register',
'show' => false,




Open root/index.php and find:
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn'))))


Replace with:
// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', /*'register', 'register2',*/ 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn'))))




Again in index.php find:
'register' => array('Register.php', 'Register'),
'register2' => array('Register.php', 'Register2'),


Replace with:
/*'register' => array('Register.php', 'Register'),
'register2' => array('Register.php', 'Register2'),*/




Open the login.template.php of your theme and find:
', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'],

Replace with:
', $txt['login_below'], /* '<a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', */ sprintf($txt['login_with_forum'],




Important:  you will also need to disable the registration process by going in Admin-->Registration-->Settings-->Method of registration employed for new members and set "Registration Disabled"

And that's it ;) it can be useful if you want your forum to be private or even if you have too many users etc...

For further reference please check out this topic --> http://www.simplemachines.org/community/index.php?topic=523689.0





Special thanks to mashby, Illori and Krash, Herman's Mixen and as always Arantor for helping me in writing this.



Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Ninja ZX-10RR

#request move as indicated in tips and tricks board.
#request deletion of this message after that ;)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Illori

that is not the only location where 'show' => $user_info['is_guest'], is found in that file the first location would be for the log in button.

also without disabling registration, you are not stopping them from registering

Sir Osis of Liver

Yep, bots don't need the button, they link directly to registration -



http://www.forum.com/index.php?action=register


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Matthew K.

Yeah, exactly as Krash. is saying, removing the button will not prevent registrations. It will just stop real people from knowing it's there (and people who don't know SMF)

Ninja ZX-10RR

Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Sir Osis of Liver

There's also a register link in the header login, for those themes that have one (i.e., Curve), which you would want to remove for consistency.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Ninja ZX-10RR

Quote from: Krash. on June 10, 2014, 03:33:52 PM
There's also a register link in the header login, for those themes that have one (i.e., Curve), which you would want to remove for consistency.
Doesn't it get deactivated in the same way by disabling the function from the admin settings? If not can you please tell me how to disable that so I can add it because I can't find where it is? After that *hopefully  O:)* everything will be correct :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Illori

i doubt it gets disabled automatically. you would find it in index.template.php

Ninja ZX-10RR

I think I found it and you are referring to this one:
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">', sprintf($txt['welcome_guest'], $txt['guest_title']), '</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
<div class="info">', $txt['quick_login_dec'], '</div>';

if (!empty($modSettings['enableOpenID']))
echo '
<br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />';

echo '
<input type="hidden" name="hash_passwrd" value="" />
</form>';
}

Still it refers to a login bar but I don't want to disable the whole bar putting */ stuff /* because I would disable the whole bar. How could I do it then leaving the login untouched but removing the register thing only?
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Sir Osis of Liver

Disabling registration does not remove the buttons/links.  User gets an error message that registration is disabled.  The header login is in index.template.php, and pulls the link text from index.english.php -



$txt['welcome_guest'] = 'Welcome, <strong>%1$s</strong>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
$txt['login_or_register'] = 'Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';



That's from Curve, it can vary with theme.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Ninja ZX-10RR

Soooo if I am correct even if I am noob at coding... Could this one be ok?

$txt['welcome_guest'] = 'Welcome, <strong>%1$s</strong>. Please <a href="' . $scripturl . '?action=login">login</a>;
$txt['login_or_register'] = 'Please <a href="' . $scripturl . '?action=login">login</a>;

(uhm I think I should leave the "register" in the txt because it would not be able to call it properly.. Correct me if I'm wrong)

And shall I edit only this one in languages or more? And for each language? D:
Tried the index.template.php but couldn't find more than what I already wrote before.
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Herman's Mixen

index.php


// If guest access is off, a guest can only do one of the very few following actions.
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', /*'register', 'register2',*/ 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn'))))


remove the "register" and "register2" from that line

also in the array of actions disable it so it can not be executed...


/*'register' => array('Register.php', 'Register'),
'register2' => array('Register.php', 'Register2'),*/
Met vriendelijke groet, The Burglar!

 House Mixes | Mixcloud | Any Intelligent fool can make things bigger, more complex, and more violent.
It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Albert Einstein

Former Godfather of our dutch community ;)

Sir Osis of Liver

That should work.  All you're doing is removing the register link from the text string.  Yes, you would have to change it in any other languages that are installed.  There's also a register link in the login window that guests see if guest access is disabled.  That's in login.template.php in kick_guest template =



', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

If registration is actually disabled from the admin panel, all the effort of faffing with index.php to remove guestAccess and removing the actions is suddenly irrelevant.

Oh, and if you use Tapatalk too. That has all kinds of 'eh, don't care about SMF's settings or rules' in it.

Ninja ZX-10RR

Quote from: Arantor on June 10, 2014, 04:26:18 PM
If registration is actually disabled from the admin panel, all the effort of faffing with index.php to remove guestAccess and removing the actions is suddenly irrelevant.
Actually yes but I believe that any human being can understand this already :) People wanting to disable totally the guest access might be experienced users as they want their forum to be private-only so probably they would like to know how to totally delete that function that's why we are trying to get rid of all of those ;)

Quote from: Arantor on June 10, 2014, 04:26:18 PM
Oh, and if you use Tapatalk too. That has all kinds of 'eh, don't care about SMF's settings or rules' in it.
Did you have any doubt about it? It's Tapatalk xD





Anyway, updated :) check it (once again) if you don't mind ;)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Arantor

But that's the point... if it's already disabled in the admin panel, you don't need to remove the declaration of the action, because it'll stop when it gets to the action itself.

Ninja ZX-10RR

I know it will not work anyhow even if people *will* be able to see it but the fact is that admins wanting their forum to be private-only for ever wouldn't like it to appear anyway as it's not possible. Why showing up an option if it doesn't work? It would be my point if I was admin of such a forum.

And besides thank you everyone huh! I couldn't do this all by myself, now I understand why noone had ever made this :P
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Arantor

Just removing the reference in index.php like that only means the difference between an error message and a login box anyway ;)

Ninja ZX-10RR

Yeah indeed but *I* don't want the registration box xD login box is ok but no the registration one :P
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Advertisement: