This is something we just implemented
workes like a charm. The idea is simple. Each user needs to have a personal page, a PROFILE PAGE.
Steps:
1 - Create and Category, Type and Template: WELCOME
2 - Link them together.(this should be a FC feature
)
3 - Create and Category, Type and Template: PROFILE
4 - Link them together.
5 - Create an item: WELCOME using the category WELCOME.
6 - Create an menu item and link it to this item set it only for registered users.
7 - Create a login module and redirect it to this menu item after login
NOW LET GO TO THE CODE
8 - Open the item.php of the WELCOME template
9 - Add this lines:
//Get User ID
Code:
$user = JFactory::getUser();
//Define Category
Code:
$category = "1"; // This category ID for the PROFILE CATEGORY
//Define DB - Query
Code:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
//Define Query
Code:
$query ->select('id')
->from('#__content')
->where('created_by="'.$user->id.'" and catid="'.$category.'" and state="1"');
//Query
Code:
$db->setQuery($query);
//Get Results
Code:
$results = $db->loadObjectList();
//Redirect the user if no profile is found
Code:
if ($results != 0 && $results != NULL && $results != "" && $results != Undefined) {
//YES profile
header( 'Location: /my-items-page.php' ) ;
} else {
//NO profile
header( 'Location: /new-profile?tmpl=component' ) ;
}
//Load Template
Code:
include(JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'tmpl_common'.DS.'item_layouts'.DS.'modular.php');
Basically what it does is, if the user does not have at least 1 item in the category profile then redirect him to the PROFILE submission page, if it already has redirect him to his profile page.
The advantages is that like this we can use FC custom fields, categories to list the users
without the need to link anything. Like this the user is linked to a profile. Also you need to verify in the form is the current log in user already has a profile, basicly is to make sure the user does not submit 2 profiles