Disable campaign update during sending process

Discussion in 'Tips and tricks' started by nemesis82, May 8, 2019.

  1. nemesis82

    nemesis82 Member

    Joined:
    Sep 19, 2018
    Messages:
    111
    Likes Received:
    16
    S.E:
    2019-12-26 01:32:41
    L.T:
    Regular
    L.C:
    7
    Hy guys,
    there is an option for disabling the "update" button once a campaign is started then paused ?
    Eg:
    With a running campaign, if I pause the sending process I can update anche change campaign information.

    Can I disable it ( option in backend or in php file ) ?
    Thanks
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,446
    Likes Received:
    2,430
    This is the answer to the issue for anyone wondering:

    If you place this code in apps/init-custom.php
    PHP:
    <?php

    Yii
    ::app()->hooks->addFilter('grid_view_columns', function($columns) {
       
       if (
    Yii::app()->controller->id != 'campaigns') {
          return 
    $columns;
       }
       
       foreach (
    $columns as $index => $column) {
          
          if (!isset(
    $column['class']) || $column['class'] != 'CButtonColumn') {
             continue;
          }
          
          if (!isset(
    $column['buttons']['update'])) {
             continue;
          }
          
          
    $columns[$index]['buttons']['update']['visible'] = '$data->editable && !$data->isPaused';
          break;
       }
       
       return 
    $columns;
    });
    Then campaigns which are paused will not show the edit button anymore.
     
  3. nemesis82

    nemesis82 Member

    Joined:
    Sep 19, 2018
    Messages:
    111
    Likes Received:
    16
    S.E:
    2019-12-26 01:32:41
    L.T:
    Regular
    L.C:
    7

Share This Page