$idholder;
$userAdded = FALSE; //Marker to check whether or not user has been added
$nonce= isset($_REQUEST['adduser-nonce'])?$_REQUEST['adduser-nonce']:'';
if (isset($_REQUEST['action']) && $_REQUEST['action'] && ($userdata->$blog_id_info == null)) {
if (!wp_verify_nonce($nonce, 'adduser-nonce'))
die('Security check failed. Please use the back button and try resubmitting the information.');
if(($options['use_password'] && ($options['password']==$_POST['user_password'])) || (!($options['use_password']== 'yes'))){
add_user_to_blog($blog_id, $user_id, $options['privilege']);
do_action( "added_existing_user", $user_id );
$userAdded = TRUE;
get_currentuserinfo();
echo "
Successfully Added
";
}
else {
echo "
" . $options['errortext'] . "
";
}
}
//error checking
if ( isset($add_user_error) && is_wp_error($add_user_errors) ) {
foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
$var = 'new_' . $var;
$var = attribute_escape(stripslashes($_POST[$formpost]));
}
unset($name);
}
//Next three statements define how the user sees the widget depending on what their status is.
if (isset($userdata->$blog_id_info)) echo '
Welcome '. $userdata->$display_name .'.
'; //message to display if user is already registered
elseif (!is_user_logged_in()) echo "
If you want to add yourself to this blog, please log in.
"; //message to display if user is not logged in
elseif ((is_user_logged_in())&&(!isset($userdata->$blog_id_info)) && !$userAdded){
echo '
Welcome '. $userdata->$display_name .'.
';?>
';
$end_wrap = '';
// These lines generate our output.
echo $before_widget . $before_title . $title . $after_title;
add_the_user();
echo $after_widget;
}
// This is the function that outputs the form in the "Sidbar Widgets" page and
// to let the users edit the widget's options.
function add_user_widget_control() {
// Get our options and see if we're handling a form submission.
$options = get_option('add_user_widget');
if ( !is_array($options) )
//initial values
$options = array('title'=>$widget_title, 'limit'=>'10', 'display'=>'name', 'button'=>'Add Me!', 'list'=>"", 'privilege'=>'subscriber', 'use_password'=>'', 'errortext'=>'Please enter the correct password to join this blog.');
if ( $_POST['sidebar_adduser-submit'] ) {
$nonce= $_REQUEST['adduser-nonce'];
if (!wp_verify_nonce($nonce, 'adduser-nonce') )
die('Security check failed. Please use the back button and try resubmitting the information.');
// Remember to sanitize and format user input appropriately.
$options['title'] = strip_tags(stripslashes($_POST['sidebar_adduser-title']));
$options['password'] = strip_tags(stripslashes($_POST['sidebar_adduser_password']));
$options['button'] = strip_tags(stripslashes($_POST['sidebar_adduser-button']));
$options['privilege'] = strip_tags(stripslashes($_POST['privilege']));
$options['errortext'] = strip_tags(stripslashes($_POST['sidebar_adduser-error']));
$options['use_password'] = strip_tags(stripslashes($_POST['use_password']));
update_option('add_user_widget', $options);
}
// Be sure you format your options to be valid HTML attributes.
$title = htmlspecialchars($options['title'], ENT_QUOTES);
$password = htmlspecialchars($options['password'], ENT_QUOTES);
$button = htmlspecialchars($options['button'], ENT_QUOTES);
$privilege = htmlspecialchars($options['privilege'], ENT_QUOTES);
$use_password = htmlspecialchars($options['use_password'], ENT_QUOTES);
$errortext = htmlspecialchars($options['errortext'], ENT_QUOTES);
?>
>
>
>