user.name -> User Name

What a great plugin OneAll is. :)

I know this has been asked before, but I couldn't find any previous discussions... I apologize for being another one asking this.

When you register with OneAll from Facebook, for example, your Facebook User Name becomes user.name. Could this be changed so that it would retain its original form? :)

Answers

  • Does anyone have any idea? :)
  • Hi,
    This convention is applied in the various plugins we provide.
    What CMS are you using for your application? (wordpress,...)

    Regards
  • Hello,

    And thanks for your answer. :) It is phpBB 3.1 we are talking about here.

    Cheers,

    Mika
  • Hi,
    Yes.
    We've added to our plugin the capability to edit the user fields (such as name) before creating the user.
    The plugin defines an event that you can listen to, and modify the user name, based on the social profile data.
    It is a bit cumbersome in PhpBB to do, but we can walk you through this.

    Some more information though: what PhpBB user name are you looking for?
    (keep in mind PhpBB does not like spaces in user logins).

    regards
  • I was thinking that, for example, mika.perkiomaki could be Mika Perkiomaki. phpBB does allow usernames like that.

    I would be happy to go through the steps. :)
  • Fred_PinelFred_PinelMember
    edited August 2016
    Ok, then, here we go.
    The steps below are based on this documentation (https://wiki.phpbb.com/Add_Listeners).
    The next steps add an additional listener to our extension, that reacts on a extension-defined event before user creation.
    The first 3 steps are just set up. Step 4 is where you custmomize it the way you want.

    1. Create this file: [ROOT]/ext/oneall/sociallogin/event/mylistener.php, with this content:
    <?php namespace oneall\sociallogin\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class mylistener implements EventSubscriberInterface { static public function getSubscribedEvents () { return array ( 'oneall_sociallogin.user_add_modify_data' => 'modify_username', ); } public function modify_username ($event) { global $phpbb_log, $user; // Shorthand, the social profile data: $social = $event['social_profile']; // Shorthand, the user credentials for phpbb: $userrow = $event['user_row']; // the following is required complexity apparently due to Symfony // Dummy username assignment for now, we'll replace in step 4.: $userrow['username'] = $social['user_formatted_name']; // also, 'user_constructed_name', 'user_full_name', $event['user_row'] = $userrow; // Remove next lines if logging not needed beyond tests. // This is useful to dump (in database) the social profile data: $phpbb_log->add ('admin', $user->data['user_id'], $user->ip, 'LOG_PROFILE_FIELD_EDIT', time(), $social ); } }
    2. In file: [ROOT]/ext/oneall/sociallogin/config/services.yml, change the contents to:
    services: oneall.sociallogin.listener: class: oneall\sociallogin\event\listener arguments: - @config - @config_text - @controller.helper - @request - @template - @user - %core.root_path% - %core.php_ext% tags: - { name: event.listener } oneall.sociallogin.mylistener: class: oneall\sociallogin\event\mylistener tags: - { name: event.listener }
    3. You may need to disable/enable the extension.

    But, please test!

    Regards.
  • Thank you! :)

    I know absolutely nothing about coding myself, but I tried to follow the above instructions carefully. The end result was this:

    Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException' with message 'A YAML file cannot contain tabs as indentation at line 1 (near " ").' in C:\xampp\htdocs\phpBB3\vendor\symfony\yaml\Symfony\Component\Yaml\Parser.php:78 Stack trace: #0 C:\xampp\htdocs\phpBB3\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php(296): Symfony\Component\Yaml\Parser->parse('\t\t\nservices:\n ...') #1 C:\xampp\htdocs\phpBB3\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php(43): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->loadFile('C:\\xampp\\htdocs...') #2 C:\xampp\htdocs\phpBB3\phpbb\di\extension\ext.php(51): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load('services.yml') #3 C:\xampp\htdocs\phpBB3\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass.php(50): phpbb\di\extension\ext->load(Array, Object(Symfony\Component\Dep in C:\xampp\htdocs\phpBB3\vendor\symfony\dependency-injection\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php on line 298
  • Yup, it must have been a typo, because after redoing it, it's all good. However, the registration format didn't change. It's still user.name and not User Name.

    This is not the biggest problem in the world, but I know we will have to change new users' usernames quite a few times to User Name.
  • Hi,
    Yes, tabs are not allowed in YAML files.

    For the user name, this only happens for new users. So, to test it, make sure you delete the account each time you make a change to the rule.
    Also, to be certain, you could log the contents of the social profile, and then pick the field you want.

    Regards
  • I was just wondering if there has been any development with this so far. It would be nice to have our Facebook users register with FirstName LastName instead of firstname.lastname. :)

Sign In or Register to comment.