1

I know enough D7 to be dangerous. I'm stumped, however, as to how to call one module from another. In this case, I want to call the simplenews module's subscribe_user hook from a custom module I'm creating. I'm having difficulty passing the multiple arguments either as a string or an array. Here are the variables the hook accepts:

$mail = '[email protected]';
$tid = 1;
$confirm = TRUE;
$source = 'unknown';
$preferred_language = NULL;

Can someone please help me call this properly?

module_invoke('simplenews', 'subscribe_user', $args);

1 Answer 1

4

use

simplenews_subscribe_user($mail, $tid, $confirm, $source, $preferred_language);

or

module_invoke('simplenews', 'subscribe_user', $mail, $tid, $confirm, $source, $preferred_language);

module invoke is parsing all given arguements and handles them to the called function.

see php documentation regarding passing variables by reference, if that might bug you someday: http://php.net/manual/en/function.call-user-func-array.php#refsect1-function.call-user-func-array-notes

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.