Possible addition to WP w3all ‘WordPress to phpBB users transfer’

User avatar
leejosepho
User w
User w
Posts: 5
Joined: Mon Mar 20, 2017 11:12 pm
Location: 200 miles south of Little Rock (usa)
Contact:

Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by leejosepho »

Hi!

To help reduce hacking attempts, I never display Usernames at my WordPress sites...and I do not want to display Usernames at my phpBB forums. So, I have added a custom ‘screen_name’ field in the phpBB user profile and I have manually copied each WordPress user’s Nickname into each corresponding phpBB ‘screen_name’ field…
…and I would suggest adding that kind of feature to the plugin’s ‘WordPress to phpBB users transfer’ option.

First ask whether a custom field such as ‘screen_name’ has already been made, then ultimately ask for that custom field name (whatever it might be) for the plugin to use while importing each user’s WordPress ‘Nickname’.
Note: In many cases the WordPress user’s ‘Nickname’ will be the same as his or her Username, so this feature could be optional if WordPress usernames are already being displayed in WordPress and nothing different is needed or wanted in phpBB.

The next challenge will be to make phpBB display the imported Nicknames in place of phpBB Usernames, and I plan to experiment with that. It seems to me it should not be difficult to capture phpBB Usernames while they are on their way to the screen and then replace them with custom phpBB Nicknames…

Many thanks for a great plugin and support!

Joe
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by axew3 »

Hello Joe! So if i've understand.

WordPress ‘Nickname’ -> transferred into phpBB as custom profile field.
Used in phpBB to display in place of username.

The first can be easily achieved, it is just an addition into query and addition of vars which values are already available.
And can be provided something easy to implement the transfer about it, and also profiles updates in case of update.
While the second require an hack to phpBB: do not know if could be easy to hook into phpBB function to replace all usernames with custom usernames instead. I never have encounter this until now, so i need to check for it a while before to correctly answer to you.
User avatar
leejosepho
User w
User w
Posts: 5
Joined: Mon Mar 20, 2017 11:12 pm
Location: 200 miles south of Little Rock (usa)
Contact:

Re: Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by leejosepho »

axew3 wrote: Tue Mar 21, 2017 11:13 pm...do not know if could be easy to hook into phpBB function to replace all usernames with custom usernames instead...
I have that working perfectly now at about line 1503 in /includes/functions_content.php:

Code: Select all

/** Begin replace username with screen_name for display /*toggle on/off*/
global $phpbb_container;
	if(!empty($user_id)) {
		$cp = $phpbb_container->get('profilefields.manager');
		$userProfileFields = $cp->grab_profile_fields_data($user_id);
	if(!empty($userProfileFields[$user_id]["screen_name"]["value"]))
		{ $username = $userProfileFields[$user_id]["screen_name"]["value"]; } }
/** End replace username with screen_name for display */
http://mavykins.blogspot.com/p/blog-page.html

edit: The above disrupts searching for a username like when wanting to send an e-mail, but mail still sends as it should.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by axew3 »

interesting ... you could also switch for real username on behind maybe, where function about search need to use real username/nicename?
On WP side it is resolved with a filter. But WP do not is a bb board complex as phpBB.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by axew3 »

for the ajax joke, that will pass all phpBB events listeners values into phpBB, on next release, i've fall
into /includes/functions_content.php, because i need to see how the thing was built. Well in true i've stop to go deep yesterday but, on
/includes/functions_content.php i've see this instead at line 1581 (where i think in case is better to hook into)

Code: Select all

/**
	* Use this event to change the output of get_username_string()
	*
	* @event core.modify_username_string
	* @var string mode				profile|username|colour|full|no_profile
	* @var int user_id				String or array of additional url
	*								parameters
	* @var string username			The user's username
	* @var string username_colour	The user's colour
	* @var string guest_username	Optional parameter to specify the
	*								guest username.
	* @var string custom_profile_url Optional parameter to specify a
	*								profile url.
	* @var string username_string	The string that has been generated
	* @var array _profile_cache		Array of original return templates
	* @since 3.1.0-a1
	*/
	$vars = array(
		'mode',
		'user_id',
		'username',
		'username_colour',
		'guest_username',
		'custom_profile_url',
		'username_string',
		'_profile_cache',
	);
	extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars)));

	return $username_string;
}
Now, there is a problem, that also you have note, if you go to change usernames all work fine in phpBB, until a link is built containing an ID of the user, but won't work if the link is built by username.
I mean for example when you select an username to PM to an user. The list show usernames, and against this value phpBB return the correct user which the PM will be send out. If the username is not the same, than phpBB fail and return you that the user not exist. The same on all other situations where links are built for queries against usernames, and not by id.
So i've stop to go more deep at this point. But what next step i will see into when i can a while (that can also point you to final correct solution (maybe, maybe not we will see)) is: the main phpBB function that retrieve data for users, if possible to see where can be added a switch.
The switch to be effective, should check against real username: association of this, should maybe be a custom field or something not very clear at moment into my mind. Most of the time the right answer come out after, you have check all what you still do not know.
User avatar
leejosepho
User w
User w
Posts: 5
Joined: Mon Mar 20, 2017 11:12 pm
Location: 200 miles south of Little Rock (usa)
Contact:

Re: Possible addition to WP w3all ‘WordPress to phpBB users transfer’

Post by leejosepho »

axew3 wrote: Sun Apr 09, 2017 1:22 pm...if possible to see where can be added a switch.
...check against real username...not very clear at moment into my mind. Most of the time the right answer come out after, you have check all what you still do not know.
Your comprehensive approach and work are very impressive, and I hope many people will ultimately benefit from it!
Post Reply