0

I am writing a function in functions.php under my theme. The function contains a cURL command that uses credentials like "account_id" and "password". These credentials are not from user input.

Where can I store these credentials? And how would I retrieve them to use them in my function?

1

You could store it as variables

$account_id = 'your_account_id';
$password = 'your password';
someFunction($account_id, $password);

Or store it in {$table_prefix}_options table and retrieve it by get_option function

$account_id = get_option('account_id');
$password = get_option('password');
someFunction($account_id, $password);

You could save this values, for example from admin panel, by update_option function.

Second option is better, because you can share your functions.php with others and they will not know your credentials. It is also important, that password shouldn't be stored as plain text.

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