Jump to content
WebFlake

Gm Prodigy

Frost
  • Posts

    25
  • Joined

  • Last visited

  • Days Won

    8

Community Answers

  1. Gm Prodigy's post in If user is already logged in, send him back to main page was marked as the answer   
    {{if \IPS\Member::loggedIn()->member_id}} {expression="\IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=forums&module=forums&controller=index'))"} {{endif}} Edit the code of the template you want this code to run on, and search loginForm then add the code at the bottom of the page and save. It will redirect users to the forums if they are logged in
  2. Gm Prodigy's post in Updating Member Titles using REST API was marked as the answer   
    You can change roles using the rest api, but to change titles you'll need to do some modifications to an app.
    probably a better way to do this but this can get you started.
     
    namespace IPS\app name goes here\api; /* To prevent PHP errors (extending class does not exist) revealing path */ if (!\defined('\IPS\SUITE_UNIQUE_KEY')) { header((isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0') . ' 403 Forbidden'); exit; } class _settings extends \IPS\Api\Controller { /** * GET /app name goes here/settings/{id} * Get information about a specific member * * @param string $member_id m * @throws 1C292/2 INVALID_MEMBER_ID The member id does not exist * @return array specifc core_member info */ public function GETitem($member_id) { try { $results = \IPS\Db::i()->select('*', 'core_members', array('member_id=?', $member_id)); $info = array(); foreach ($results as $k => $v) { $info[$k] = $v; } if (empty($info)) { throw new \IPS\Api\Exception('INVALID', '1XBH292/2', 404); } return new \IPS\Api\Response(200, $info[0]); } catch (\OutOfRangeException $e) { throw new \IPS\Api\Exception('INVALID_MEMBER_ID', '1XBH292/2', 404); } } /** * POST /app name goes here/settings/{member_id} * Get information about a specific member * * @param string $member_id members id * @apiparam string Member_Title changes member title * @throws 1C292/2 INVALID_MEMBER_ID * @return void */ public function POSTitem($member_id) { $results = \IPS\Db::i()->select('*', 'core_members', array('member_id=?', $member_id)); $info = array(); foreach ($results as $k => $v) { $info[$k] = $v; } if (empty($info)) { throw new \IPS\Api\Exception('INVALID_MEMBER_ID', '1XBH292/2', 404); } $worked = true; if (isset($_GET['rank'])) { try { $query = \IPS\Db::i()->query("UPDATE core_members SET member_title='" . $_GET['rank'] . "' WHERE member_id='$member_id'"); if ($query == false) { $worked = false; } } catch (\InvalidArgumentException $e) { throw new \IPS\Api\Exception('Rank may not have been updated', '2F295/7', 400); } } return new \IPS\Api\Response(200, $worked ? "OK" : "Failed"); }  
×
×
  • Create New...