How to hook into fivestar_ajax_submit function? I have to add custom HTML element for rate stars and I tried to this with alter fivestar_custom_widget form and set:

$form['actions']['submit']['#ajax']['callback'] = 'MODULE_fivestar_ajax_submit';


I created MODULE_fivestar_ajax_submit function where I call original fivestar_ajax_submit.
My problem is that I can't instruct $form to use my function in place of original code.

-- edit --

In MYMODULE_form_alter() I'v got:

if ($form_id == 'fivestar_custom_widget') {
    $arg0 = arg(0);
    $arg1 = arg(1);
    if ($arg0 == 'node' &amp;&amp; !empty($arg1) &amp;&amp; ctype_digit($arg1)) {
        $node = node_load($arg1);
        $form['votes_counter'] = array(
            '#markup' =&gt; '&lt;div class="votes-countes"&gt;' . format_plural($node-&gt;field_rating[LANGUAGE_NONE][0]['count'], '1 vote', '@count votes') . '&lt;/div&gt;'
        );
        $form['#submit'] = array(
            'MYMODULE_fivestar_form_submit'
        );

        $form['actions']['submit']['#ajax']['callback'] = 'MYMODULE_fivestar_ajax_submit';
        $form['#submit'] = array('MYMODULE_fivestar_ajax_submit');
    }
}


and submit function:

function MYMODULE_fivestar_ajax_submit($form, $form_state) {
    $result = fivestar_ajax_submit($form, $form_state);
    $result['#commands']['data'] .= format_plural(100, '1 vote', '@count votes');
    return $result;
}
My friend helped me with this solution:

function MYMODULE_element_info_alter(&amp;$info) {
    $info['fivestar']['#process'][] = 'MYMODULE_fivestar_process';
}

function MYMODULE_fivestar_process($element) {
    $element['vote']['#ajax']['callback'] = 'MYMODULE_fivestar_ajax_submit';
    return $element;
}

function MYMODULE_fivestar_ajax_submit($form, $form_state) {
    $result = fivestar_ajax_submit($form, $form_state);

    $type = $form_state['build_info']['args'][1]['content_type'];
    $id = $form_state['build_info']['args'][1]['content_id'];
    $votes = fivestar_get_votes($type, $id, 'vote', $GLOBALS['user']-&gt;uid);

    $result['#commands'][] = array(
        'command' =&gt; 'insert',
        'method' =&gt; 'replaceWith',
        'selector' =&gt; 'span.vote-count',
        'data' =&gt; '&lt;span class="vote-count"&gt;' . format_plural($votes['count']['value'], '1 vote', '@count votes') . '&lt;/span&gt;',
        'effect' =&gt; 'fade'
    );
    return $result;
}


This code adds and change votes counter displayed after fivestar voting widget.