1 jefff_1979 Feb 01, 2009 15:56
3 edb Feb 01, 2009 16:53
Okay so I wanted it to be a selectable widget. Seemed to me the widget with the dropdown box that lets me put a "log in" link on the page would be cool, so that's the first file you hack.
Open inc/widgets/widgets/_menu_link.widget.php and find something very very much like this, then make it be exactly like this:
$menu_link_widget_link_types = array(
'home' => T_('Blog home'),
'arcdir' => T_('Archive directory'),
'catdir' => T_('Category directory'),
'latestcomments' => T_('Latest comments'),
'ownercontact' => T_('Blog owner contact form'),
'login' => T_('Log in form'),
'register' => T_('Registration form')
);
The change is adding a comma on the 'login' line and the 'register' line.
Now scroll down to roughly line 160 where you find a "case" for 'login', then add a "case" for 'register' after it. You will end up with this:
case 'login':
if( is_logged_in() ) return false;
$url = get_login_url();
$text = T_('Log in');
break;
case 'register':
if( is_logged_in() ) return false;
$url = get_register_url();
$text = T_('Register');
break;
case 'home':
default:
The problem now is that there is no such thing as a "get_register_url" function, so I hacked it in to a different file. Open inc/users/model/_user.funcs.php and look around line 208 for this bit:
$r = $before;
$r .= '<a href="'.$htsrv_url_sensitive.'register.php'.$redirect.'" title="'.$link_title.'">';
$r .= $link_text;
$r .= '</a>';
$r .= $after;
return $r;
}
After that add two blank lines then the following function:
/**
* Get url to register - THIS IS A HACK!
*
* @return string
*/
function get_register_url()
{
global $htsrv_url_sensitive, $edited_Blog, $generating_static;
if( !isset($generating_static) )
{ // We are not generating a static page here:
$redirect = regenerate_url( '', '', '', '&' );
}
elseif( isset($edited_Blog) ) // fp> this is a shady test!! :/
{ // We are generating a static page
$redirect = $edited_Blog->get('url'); // was dynurl
}
else
{ // We are in a weird situation
$redirect = '';
}
if( ! empty($redirect) )
{
$redirect = '?redirect_to='.rawurlencode( url_rel_to_same_host( $redirect, $htsrv_url_sensitive ) );
}
return $htsrv_url_sensitive.'register.php'.$redirect;
}
Upload them and you should be able to select "Register" from that widget. Logged in peeps won't see it of course, and I use it right next to the same widget with "Log In" selected.
Oh yeah back yer files up before you hack 'em cuz there ain't nothin' worse than trusting a free hack only to find out there really was a price ;)
4 jefff_1979 Feb 01, 2009 17:23
You rock! Now there won't be any confusion when people are looking to register...
Thanks a lot man!
Yes, give me a few minutes though. You will have to hack two files to get 'er done the way I did it.