문제

I want to use a placeholder from the Login plugin in an xPDO SQL query, eg:

$userid = [[+id]];

$sql = "SELECT * FROM `table` WHERE `id` = $userid";

$modx->query($sql);

However, if I echo the $userid var I just get Array.

Would anyone know the proper way of converting a ModX Placeholder into a PHP var?

도움이 되었습니까?

해결책

MeltingDog,

$modx->toPlaceholder() is the only function which used $modx->getPlaceholder() and only serves to search a placeholder array created by $modx->toPlaceholder() and $modx->toPlaceholders() calls via PHP snippets and classes.

What you wanted to do is described in the Login documentation via the $hook variable.

The user is available via the means Login is used: $userObject = $hook->getValue('register.user'); or $userObject = $hook->getValue('updateprofile.user');

In both cases the code would be completed thusly:

$userid = $user->getPrimaryKey();

or

$userid = $user->id;

or

$userid = $user->get('id');

다른 팁

I found it:

$userid = $modx->getPlaceholder('id');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top