Discuz! X2.5QQ登录流程修改方法

本文档介绍如何优化注册、完善资料流程,请注意,本文档仅适合Discuz! X2.5版本。
应用场景:Discuz! X2.5对QQ登录流程进行了修改,默认为QQ游客组,如果QQ初次登录后进行发帖或使用漫游应用时,提示权限有限,需完善资料,致使部分以QQ登录用户为主的站点用户流失严重。

主要修改思路:修改QQ首次登录后的跳转到完善资料页,并在跳转之前增加一段随机生成电子邮件地址代码,邮件地址后缀取的是网站的域名;完善资料页调用系统模版的register.htm文件,对是否为QQ首次登录做出判断,接到$_GET的电子邮件地址并隐藏显示,无需用户填写,用户名自动获取。

修改方法如下:

需修改2处文件,修改文件后请到后台更新缓存。

1、source/plugin/qqconnect/connect/connect_login.php

修改方法:

找到$utilService->redirect($referer); ,注释掉;用下面的代码替换,并保存;

$emailstr = substr(str_shuffle(adcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM1234567890), 0, 12);

$len = strlen($_G['siteurl']);

$firstsub = substr($_G['siteurl'], 0, $len-1);

$poss = strpos($firstsub, '.');

$firstpreg = substr($firstsub, $poss+1);

$emailfix = $emailstr.'@'.$firstpreg;

dheader('Location: member.php?mod=connect&referer=index.php&emailfix='.$emailfix);

2、template/default/member/register.htm

修改方法:

找到以下内容,

<div class="rfm">
	<table>
		<tr>
			<th><span class="rq">*</span><label for="{$this->setting['reginput']['email']}">{lang email}:</label></th>
			<td><input type="text" id="{$this->setting['reginput']['email']}" name="" autocomplete="off" size="25" tabindex="1" class="px" value="$hash[0]" required /><br /><em id="emailmore">&nbsp;</em></td>
			<td class="tipcol"><i id="tip_{$this->setting['reginput']['email']}" class="p_tip">{lang register_email_tips}</i><kbd id="chk_{$this->setting['reginput']['email']}" class="p_chk"></kbd></td>
		</tr>
	</table>
</div>

用一下内容进行替换,并保存。

<!--{if $_GET[emailfix]}-->
	<div class="rfm">
		<table style="display:none">
			<tr>
			        <!--<th><span class="rq">*</span><label for="{$this->setting['reginput']['email']}">{lang email}:</label></th>-->
		                <td><input type="hidden" id="{$this->setting['reginput']['email']}" name="" autocomplete="off" size="25" tabindex="1" class="px" value="$_GET[emailfix]" required /><br /><em id="emailmore">&nbsp;</em></td>
			        <td class="tipcol"><i id="tip_{$this->setting['reginput']['email']}" class="p_tip">{lang register_email_tips}</i><kbd id="chk_{$this->setting['reginput']['email']}" class="p_chk"></kbd></td>
			</tr>
		</table>
	</div>
<!--{else}-->
	<div class="rfm">
	        <table>
	                <tr>
				<th><span class="rq">*</span><label for="{$this->setting['reginput']['email']}">{lang email}:</label></th>
				<td><input type="text" id="{$this->setting['reginput']['email']}" name="" autocomplete="off" size="25" tabindex="1" class="px" value="$hash[0]" required /><br /><em id="emailmore">&nbsp;</em></td>
				<td class="tipcol"><i id="tip_{$this->setting['reginput']['email']}" class="p_tip">{lang register_email_tips}</i><kbd id="chk_{$this->setting['reginput']['email']}" class="p_chk"></kbd></td>
			</tr>
		</table>
	</div>
<!--{/if}-->

Comments

No comments yet. Why don’t you start the discussion?

发表回复