how to login with custom field?

6 years 8 months ago - 6 years 8 months ago #296105 by saman2
how to login with custom field? was created by saman2
hi
in know i can login method to use email or username.
how my users can login with other custom field instead of username or even password?
for example use phonenumber instead of password or use for example firstname or lastname instead of username.
such as this extensions.joomla.org/extension/login-with-email-or-phone-for-virtuemart/plugin
i can write some custom php code to do this.
please guide me.

Please Log in to join the conversation.

6 years 8 months ago #296123 by krileon
Replied by krileon on topic how to login with custom field?
You can't without creating a Joomla authentication plugin to do so if one doesn't already exist. You'd then set the login method in CB > Configuration to use authentication plugins.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 8 months ago - 6 years 8 months ago #296145 by saman2
Replied by saman2 on topic how to login with custom field?
i'm use this PHP code and it's work but i don't know is it good or secure code for joomla or not? or can i use Substitutions in my code?
i know it's not best performance because i'm using "inner join" in my query.
can you guide me more ? i want release this plugin in JED when it's complete.
this is core of my plugin:
class plgAuthenticationEmail extends JPlugin {

    /**
     * This method should handle any authentication and report back to the subject
     */
    function onUserAuthenticate(&$credentials, $options, &$response) {
        // Get a database object
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->select('username, password');
        $query->from('#__users inner join #__comprofiler ON #__users.id=#__comprofiler.id');
        $query->where('cb_FOO LIKE ' . $db->Quote($credentials['username']));

        $db->setQuery($query);
        $result = $db->loadObject();

        if ($result) {
            // why mess with re-creating authentication - just use the system.
            $credentials['username'] = $result->username;
            require_once JPATH_PLUGINS . '/authentication/joomla/joomla.php';
            PlgAuthenticationJoomla::onUserAuthenticate($credentials, $options, $response);
        } else {
            $response->status = JAuthentication::STATUS_FAILURE;
            $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS');            
        }
    }

}

Please Log in to join the conversation.

6 years 8 months ago #296177 by krileon
Replied by krileon on topic how to login with custom field?
Review existing Joomla authentication plugins for examples. We do not provide coding support here. If you need help with coding an authentication plugin I suggest reviewing Joomlas documentation and become familiar with Joomla API or try posting on Joomlas forums.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.195 seconds

Facebook Twitter LinkedIn