Bind Extension to Outbound Trunk

I really really want to be able to specify that when extension xxx dials outbound it uses X trunk.

I have two people renting offices / phones from me and I want to make it so they don’t have to dial a prefix. (they keep forgetting.)

I am willing to pay for support / donate to the project to get this resolved.

are you runnnig the 2.2 branch??


in case you do not know how to do a manul install
cd /usr/src
wget http//
cd /var/www/html/admin/modules/
tar -zxvf /usr/src/customcontexts.tgz

All is working fantastically!

One minor bug… had to manually specify the context within the extension’s context feild, (the drop down list would keep resetting itself to “blank”

So, who gets my gratitude, $50 AUD?


there is a donate button on the left side of the main freepbx site. That is the best place to send such offers of gratitude, they will directly benefit the project.

This looks amazing, should have this in the base setup as its really useful.

I am seeing an error at the top of the custom page whenever I select.

Warning: Invalid argument supplied for foreach() in /var/www/html/admin/modules/customcontexts/ on line 589

anyone else seen this and no a fix?


Hi there,

I run FreePBX with Devices and Users. This module allows me to choose a custom context for the devices but not for Users. Does anyone know if there is a way to do the same for Users. The reason:

We have a bunch of phones that are used by different people. I want them to automaticly dail out a certain trunk depending on what user is using the phone.

Any Ideas?

Btw: I have FreePBX and I’m seeing the same Warning. But all seems to work.


I do not know about users vs devices
but the error I think comes from not creating a time condition under the custom context module first.


there is an add-on module (developed by one of the other guys on this forum) which allows outbound groups to be created.

Info & download link in the original thread, here:


thanks for the tip. The module doesn’t seem to work for me, after installing it hangs freepbx, till i reboot. And then i have php errors when I open it. I’ll try to look into more this weekend, and will post my problems in the thread for the module.

Thank you again,

Is it the Outgroups module that you are talking about causing FreePBX to hang? If so, I haven’t heard of that problem before. Which versions of FreePBX and Asterisk are you using?

As far as the other problems with PHP errors, they are fixed in the latest version (0.1.6). I borrowed the code for the Extensions page from the Custom Contexts module and it has a few “issues”. I rewrote that code from scratch and all the problems should be resolved in the new version.

If you still see any issues after upgrading, please let me know.

I’m having the same issue with the devices being reset to blank after update.
How do you get around that?
I’m trying to bind users/devices 1xx to zap/g0 and 2xx to zap/g1

Custom contexts worked for me.
The pulldown resets to blank but the actual context field changes and works when you save.
I was able to use custom-contexts to restrict extensions to specific trunks and it’s been going for a few days without issue.


I’ve just tried installing ‘Custom Contexts’ to fix certain extensions to specific trunks.

It does this, but when set to the ‘new’ context the extensions lose access to hints, or at least the Polycom phones are unable to obtain the status of other extensions.
(The extensions are all available locally, only certain trunks are restricted).

As far as I can see, the only restrictions I have set in the new context are those relating to outbound routes, almost everything is set to ‘allow’.

Setting the extension context back to default immediately allows the hints / line status lamps to work again as before.

Does anyone have any info on getting both hints/lamps and custom contexts working together?

Well, all internal extension hints started working OK on their own(?)…

For trunk (ZAP) hints, it is neccessary to have a section in extensions_custom.conf for each outbound route block, containing the relevent hint lines.

I originally added the ZAP hints in outbound-allroutes-custom.
This is apparently not used when custom contexts is used - the hints must go in each individual outrt-(name)-custom block, like

exten => 151,hint,ZAP/1
exten => 152,hint,ZAP/2
exten => 153,hint,ZAP/3
exten => 154,hint,ZAP/4

The hints are then available to phones that include that route in their context.

Hi, i also want to bind trunk with extension, Example

extension 1 should make outbound calls from 1 Trunk
extension 2 should make outbound calls from 2 Trunk

I have trixbox latest version installed (Trixbox )


sirm766: Trixbox has taken it upon themselves to fork FreePBX (see “News Announcements” in upper right hand column on this page), and while the changes at this point may be relatively minor, we have no way of knowing whether advice we give you here will work with the latest versions of Trixbox. They have decided that they want to take over coding and support, so I would respectfully suggest that you either ask your questions in one of their forums, or if you want to run “true” FreePBX then use a distribution that includes it, such as PBX in a Flash or Elastix. Note that I am NOT a FreePBX developer, so this should not be taken as an “official” position of the FreePBX team, just as a bit of friendly advice.

To FIX this error after installing Custom Context, (Warning: Invalid argument supplied for foreach() in /var/www/html/admin/modules/customcontexts/ on line 589) just create a “custom context times”, no more errors after that.
Thank you!

That error was addressed in 0.3.3 or 0.3.4. which is available here in the FreePBX site. Please take a look at using the latest module code for better results.

Is there a working solution that goes with I didn’t want to go installing modules if there is a major difference in the internals. Or is this funcionality somehow built in now? I looked but couldn’t find it.

yes it works