Hi Ahmed,
followed up with our team and they have sent the following:
They suspect the following 2 lines will get you the outcome you are aiming for:
$userUtils = \Drupal::service('ibm_apim.user_utils');
$org = $userUtils->getCurrentConsumerOrg();
As it will return an object with the attributes of the currently selected org - e.g $org['url']
would give the url of that org.
let me know if this works!
------------------------------
Gabriel Marte Blanco
Austin TX
------------------------------
Original Message:
Sent: Mon January 09, 2023 09:46 AM
From: Ahmed Ashraf
Subject: How to programmatically get selected consumer organization in developer portal?
Hello all,
I am customizing the 'create application' action in developer portal by enabling php module that implements the hook_form_alter of the create application form, what I need is to get the current selected consumer organization.
For example, I need to access some variable that indicates that 'Test Org 2' is the selected organization at that moment.

Thanks,
------------------------------
Ahmed Ashraf
------------------------------