How to implement a custom user task using hooks?

Home Forums WordPress Plugins Bulk Task Editor How to implement a custom user task using hooks?

Tagged: ,

Viewing 0 reply threads
  • Author
    Posts
    • #8908
      Rafasashi
      Keymaster

      To implement a custom user task using hooks with Bulk Task Editor register the task:

      add_action( 'rewbe_user_actions', function($actions){
      
                $actions[] = array(
      
                     'label'  => 'Name of your task',
                     'id'     => 'bulk_task_name',
                     'fields' => array(
                          array(
                               'name'    => 'var_1',
                               'type'    => 'select',
                               'options' => array(
                                    'value_1' => 'Option 1',
                                    'value_2' => 'Option 2',
                                    'value_3' => 'Option 3',
                               ),                    
                          ),
                          array(
                               'name' => 'var_2',
                               'type' => 'text',
                          ),
                     ),
                );
      
           
           return $actions;
           
      },10,1);
      

      Add the callback function of your task:

      add_action('rewbe_do_user_{bulk_task_name}',function($user,$args){
           
           if( !empty($args['var_1']) && !empty($args['var_2']) ){
                
                $var_1 = sanitize_title($args['var_1']);
      
                $var_2 = sanitize_text_field($args['var_2']);
                
                // your logic here
           }
           
           return $user;
           
      },10,2);
Viewing 0 reply threads
  • You must be logged in to reply to this topic.