Topic-icon force password check

Active Subscriptions:

None
14 years 10 hours ago #3566 by nimda79
Replied by nimda79 on topic force password check
Would this be able to do the same for JomSocial?

I had to do some crazy code re-vamping to get it to work but it does....
<?php
/**
 * @package        Force Password Change
 * @copyright (C) 2010 by Source Coast - All rights reserved
 * http&#58;//www.sourcecoast.com
 * http&#58;//www.cmsmarket.com
 * http&#58;//www.covertapps.com
 * @license http&#58;//www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.plugin.plugin');

class plgSystemForcePasswordChange extends JPlugin
{
	function plgSystemForcePasswordChange(&$subject, $config)
	{
		parent&#58;&#58;__construct($subject, $config);
	}

	function onAfterRoute()
	{
                global $mainframe;

                // Don't do anything if this is the administrator backend or debugging is on
                if($mainframe->isAdmin() || JDEBUG) {
                        return;
                }

		$user = &JFactory&#58;&#58;getUser();

		$option = JRequest&#58;&#58;getVar('option');
		$view = JRequest&#58;&#58;getVar('view');
		$task = JRequest&#58;&#58;getVar('task');
		$savetask = JRequest&#58;&#58;getVar('action');
		// no_html is sent by Mighty Registration for ajax checks, so we need to ignore them
		$noHtml = JRequest&#58;&#58;getVar('no_html');

		$editProfileOption = "com_community";
		$editProfileSaveTask = "save";
		$editProfileView = "profile";
		$editProfileTask = "edit";

		if(!$user->guest && $user->lastvisitDate == "0000-00-00 00&#58;00&#58;00" && $noHtml != "1")
		{
			// The user is not a guest and their lastvisitDate is zeros
			if($option == $editProfileOption && $savetask == $editProfileSaveTask)
			{
				// The user is saving their profile

				// Set the last visit date to a real value so we won't continue forcing them to update their profile
				$user->setLastVisit();
				$date = JFactory&#58;&#58;getDate();
				$user->lastvisitDate = $date->toMySQL();
			}
			else if(!($option == $editProfileOption && $view == $editProfileView && $task == $editProfileTask))
			{
				// The user is not on the edit profile form

				// Update lastvisitDate back to zero
				$dbo = &JFactory&#58;&#58;getDBO();
				$query = "UPDATE #__users ".
					"SET lastvisitDate = ".$dbo->quote("0000-00-00 00&#58;00&#58;00")." ".
					"WHERE id = ".$dbo->quote($user->id);
				$dbo->setQuery($query);
				$dbo->query();
	
				// Redirect to edit profile
				$app = &JFactory&#58;&#58;getApplication();

				$app->redirect(
					"index.php?option=".$editProfileOption."&view=".$editProfileView."&task=".$editProfileTask,
					$this->params->get("message", "You must update your password before continuing to use the site.")
				);
			}
		}
	}
}
The topic has been locked.
Support Specialist
14 years 7 hours ago #3570 by alzander
Replied by alzander on topic force password check
Thanks for posting back your solution. I will take a look at it and incorporate it into the released version. If I can, I will add a parameter to make it easier for others to switch which profile page they want to redirect to.

Thanks again for your help!
The topic has been locked.
Active Subscriptions:

None
13 years 9 months ago #3914 by tk42i
Replied by tk42i on topic force password check
Hi. I love this plugin. To continue this conversation....I would like to force my new users to complete additional fields when they are changing their password, but I am using community builder. Does anyone have any advice before I start custom coding my own solution on top of this plugin?
The topic has been locked.
Support Specialist
13 years 9 months ago #3945 by alzander
Replied by alzander on topic force password check
If you're using CB, why don't you just mark the fields as required? I'm guessing you're maybe creating the account for them and then want them to fill it out after they log in?

There should be a pretty easy way to check profile status, or a specific field at least, to see if it has values. If not, redirect to the profile repeatedly until that field has something. Won't guarantee all fields are complete, but at least you'll know they did something...

Just some thoughts.
The topic has been locked.