Hi all. I spent some hours trying to understand how to add custom functionalities to aMember. I achieved the most of what I wanted, but now I'm stuck. I'm trying is to add a new button to each row of the Browse User page beside the Merge User button. It should be a simple link to an external resource. It should be made like this: https://www.examplesite.com/usertrack.php?user=%aMemeberUsername% I found information about something similar, but for a different area, here: http://www.amember.com/forum/threads/adding-another-action-link-to-grid-rows.22801/ Moreover, is there a guide to learn how to do it? Thank you and best regards.
You can use the following code in site.php http://www.amember.com/docs/Site.php_file PHP: Am_Di::getInstance()->hook->add('gridUserInitGrid', function (Am_Event_Grid $e) { $e->getGrid()->actionAdd(new Am_Grid_Action_Url('myaction', 'My Action', '/path/to?uid={login}')) ->setTarget('_top');}); I am afraid there is not guide but aMember has open source code so you can just check code.
Thanks a lot and Merry Christmas Eve. Another short question to better understand how to proceed for future customization. Disclaimer: I'm not an expert yet about aMember source code. I started modifying it only a couple of weeks ago. 2nd disclaimer: Sorry if I'll say something stupid and sorry for my English mistakes too (I'm Italian). The parameter "gridUserInitGrid", as much as "gridSubusersUserInitGrid"... Where did they come from? I think - correct me if I'm wrong - they're necessary to relate the actionAdd call to the specific getGrid call (the one used to render the user list, right?). Searching inside all the source code, I found no reference to "gridUserInitGrid". There is only a function called "onGridUserInitGrid" inside Bootstrap.php. Am I missing something? How did you identify that specific parameter? Thanks again and have a good day!
First of all Merry Christmas! Regarding grids and its events: You need to check two files: library/Am/Grid/Editable.php library/Am/Grid/ReadOnly.php You will find grid class definition. It has a number of event points that you can use to extend grid (add column/add action etc). You can see event constants within Grid classes: PHP: const CB_RENDER_TABLE = 'onRenderTable'; const CB_RENDER_PAGINATOR = 'onRenderPaginator'; const CB_RENDER_TITLE = 'onRenderTitle'; const CB_RENDER_CONTENT = 'onRenderContent'; const CB_RENDER_STATIC = 'onRenderStatic'; const CB_TR_ATTRIBS = 'onGetTrAttribs'; const CB_BEFORE_RUN = 'onBeforeRun'; const CB_NO_RECORDS = 'onNoRecords'; const CB_MAKE_URL = 'onMakeUrl'; const CB_INIT_GRID = 'initGrid'; const CB_INIT_GRID_FINISHED = 'initGridFinished'; const CB_BEFORE_INSERT = 'beforeInsert'; const CB_AFTER_INSERT = 'afterInsert'; const CB_BEFORE_UPDATE = 'beforeUpdate'; const CB_AFTER_UPDATE = 'afterUpdate'; const CB_BEFORE_SAVE = 'beforeSave'; const CB_AFTER_SAVE = 'afterSave'; const CB_BEFORE_DELETE = 'beforeDelete'; const CB_AFTER_DELETE = 'afterDelete'; const CB_VALUES_TO_FORM = 'valuesToForm'; const CB_VALUES_FROM_FORM = 'valuesFromForm'; const CB_INIT_FORM = 'initForm'; This string token gridUserInitGrid is compound from two parts: First part gridUser - is event id of exact grid instance to target it (such as user (gridUser), products (gridProduct), coupon batches (gridCouponBatch) etc.). You can see how this id is set in code: PHP: $grid->setEventId('gridUser'); Second part InitGrid is event within grid (Am_Grid_ReadOnly::CB_INIT_GRID), it can be any event from available (you can see list of event above). You only need to capitalize first latter of event name. This token gridUserInitGrid is used to bind your event handler to exact grid and its exact event. I hope it help. Best Regards.