douli1306 2013-08-22 16:35
浏览 23
已采纳

创建限制为Joomla组的PHP页面

I've created a php page, but the content may only be available for a particular group Joomla.

The file is within a folder, and this folder is in the root of the site with joomla!

How do I get my php page, check the user data: UserGroupID

/ root
/ root / administrator
/ root / components
...
/ root / folder
/ root / folder / file.php

And file.php

$content_to_group_id = 7;

if ($group_id_user == $content_to_group_id) {
// show
} else {
// error
}
  • 写回答

3条回答 默认 最新

  • dplo59755 2013-08-22 17:03
    关注

    Try this,

    Load joomla frame work to your page with following codes.

    define( '_JEXEC', 1 );
    define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
    define( 'DS', DIRECTORY_SEPARATOR );
    
    require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
    require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
    
    $mainframe =& JFactory::getApplication('site');
    $mainframe->initialise();
    
    $user = JFactory :: getUser();//if you want to get current users details then empty params other wise pass like JFactory::getUser($user_id);
    echo "<pre/>";
    print_r($user)//This resulted array have the user group of the user.
    

    Hope its help you..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真