Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to put a value from the registration form into a function


peterverkooijen
Participant

@peterverkooijen

The phplist-dual-registration plugin also takes input from registration. It has this function:

function subscribe($input_data) {
if (!wpphplist_check_curl()) {
echo 'CURL library not detected on system. Need to compile php with cURL in order to use this plug-in';
return(0);
}
// $post_data = array();
foreach ($input_data as $varname => $varvalue) {
$post_data[$varname] = $varvalue;
}
// Ensure email is provided
$email = $post_data[$this->email_id];
// $tmp = $_POST['lid'];
// if ($tmp != '') {$lid = $tmp; } //user may override default list ID
if ($email == '') {
echo('You must supply an email address');
return(0);
}
// 3) Login to phplist as admin and save cookie using CURLOPT_COOKIEFILE
// NOTE: Must log in as admin in order to bypass email confirmation
$url = $this->domain . "admin/";
$ch=curl_init();
if (curl_errno($ch)) {
print '<h3 style="color:red">Init Error: ' . curl_error($ch) .' Errno: '. curl_errno($ch) . "</h3>";
return(0);
}

$post_data='action=subscribe&group_ids[]='.$this->lid.'&email_address='.$this->email_id.'&firstname='.$this->name_id;

Is the $post_data line what I need? Something like this?:

function subscribe($input_data) {

// $post_data = array();
foreach ($input_data as $varname => $varvalue) {
$post_data[$varname] = $varvalue;
}

$email = $post_data[$this->email_id];
$name = $post_data[$this->name_id];
}

And then I could use $email and $name in my function to “do stuff” with?

Or can I use $post_data[$this->email_id] etc. directly? Is that the simple answer to my original question?

Why is the $post_data commented out?! Don’t I need it?

Do I need other pieces to make it work? For which fields would this work; only those from wp_users or xprofile as well? What about custom fields, including the real name/first name/last name mess?

Skip to toolbar