41
trabis
Re: Paid access to some parts of the website
  • 2009/1/18 21:14

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

niei0637 wrote:
$uid is_object($xoopsUser) ? 
echo 
$uid;
$xoopsUser->getVar('uid') : 0;



But this is not correct code.
Should be like this:
$uid is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
echo 
$uid;


This is also not correct
require(XOOPS_ROOT_PATH.'/mainfile.php');


Because XOOPS_ROOT_PATH is defined in mainfile.php
This way you will get nothing or you will have mainfile included twice.

When that file is included XOOPS_ROOT_PATH is already defined.
Just erase:
require(XOOPS_ROOT_PATH.'/mainfile.php');
require(
XOOPS_ROOT_PATH.'/header.php');


or replace by:
if (!defined('XOOPS_ROOT_PATH')) {
    die(
"XOOPS root path not defined");
}




42
Mazarin
Re: Paid access to some parts of the website
  • 2009/1/18 21:39

  • Mazarin

  • Just can't stay away

  • Posts: 533

  • Since: 2008/12/10


Sorry, messed up in the code. What I do have is in fact:
$uid is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0
echo 
"uid: $uid";


OK, so I excluded the mainfile and the header, but the result remains the same. When I print out the uid I only get a 0, as the is_object($xoopsUser) function returns a false (verified this and it always returns false). I'm probably doing something really simple and stupid wrong here, but I can't figure out what.

43
trabis
Re: Paid access to some parts of the website
  • 2009/1/18 22:10

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


add

global $xoopsUser;

at the beginning of the file.

44
deka87
Re: Paid access to some parts of the website
  • 2009/1/19 6:30

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


sorry for breaking into your discussion again, but I want to make more benefits for the paid members. As one of the benefit of that 'mygroup' I want to put their profiles in top of the search results in modules/profile/search.php. I tried to play with the
$verGrupos $thisUser->getGroups();
if (!
in_array("6"$verGrupos) ) {
code but failed to get users who belong to the 6th group (which is 'mygroup') appear first in the search results.
Mind anchors

45
ghia
Re: Paid access to some parts of the website
  • 2009/1/19 10:14

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
if (!in_array("6"$verGrupos) ) {
Before you used the name instead of the number?

46
deka87
Re: Paid access to some parts of the website
  • 2009/1/19 10:35

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


well before i used the code provided by trabis to show restricted content for 'mygroup' members.

the code with numbers was taken from the XOOPS FAQ to show content depending on the user's profile (or his uname in the search results) that you are watching no matter what your group is. It's just that Trabis "extracted" the group name and the aforesaid code is stuck with its number.
Mind anchors

47
trabis
Re: Paid access to some parts of the website
  • 2009/1/19 13:34

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Deleted, sorry, wrong info :(

48
deka87
Re: Paid access to some parts of the website
  • 2009/1/19 14:01

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


thanks for correcting the code, but how do I need to modify the profile/search.php in order to place the 'mygroup' members in top of search results ?
Mind anchors

49
trabis
Re: Paid access to some parts of the website
  • 2009/1/19 14:02

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Have you tried this ?
$verGrupos $thisUser->getGroups();
if (
in_array("6"$verGrupos) ) {

50
trabis
Re: Paid access to some parts of the website
  • 2009/1/19 14:03

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

deka87 wrote:
thanks for correcting the code, but how do I need to modify the profile/search.php in order to place the 'mygroup' members in top of search results ?


Forget my code, I was mistaken. Your code should work with a minor change, look my previous post.

Login

Who's Online

357 user(s) are online (203 user(s) are browsing Support Forums)


Members: 0


Guests: 357


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits