Duplicate this plugin…
-
Hey,
Am using the sidebar login plugin and i have it on one sidebar , i need to duplicate it so i can use it on another sidebar i have on my wordpress, i have the code below i tried to duplicate it but it gave me an error when i tried to install the duplicaye plugin…any help guys…
<?php /* Plugin Name: Sidebar Login Description: Adds a sidebar widget to let users login Author: Mike Jolley, [email protected] Version: 1.55 Author URI: https://blue-anvil.com */ function widget_sidebarLogin_init() { //Set a cookie now to see if they are supported by the browser. setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); if ( SITECOOKIEPATH != COOKIEPATH ) setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); // Login user widget_sidebarLogin_check(); if ( !function_exists('register_sidebar_widget') ) return; function widget_sidebarLogin($args) { extract($args); // Get user info global $userdata,$user_identity; get_currentuserinfo(); if ($userdata->ID>0) { // User is logged in echo $before_widget . $before_title . "Welcome ".$user_identity . $after_title; echo ' <ul class="pagenav"> <li class="page_item"><a href="'.get_bloginfo('wpurl').'/wp-admin">Dashboard</a></li> <li class="page_item"><a href="'.get_bloginfo('wpurl').'/wp-admin/profile.php">Profile</a></li> <li class="page_item"><a href="'.get_bloginfo('wpurl').'/wp-login.php?action=logout&redirect_to=https://'.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'].'">Logout</a></li> </ul> '; } else { // User is NOT logged in!!! echo $before_widget . $before_title . "Member Login" . $after_title; // Show any errors $sbl_errors=$_POST['sbl_errors']; if ( !empty( $sbl_errors ) ) { if ( is_array( $sbl_errors ) ) { $newerrors = "\n"; foreach ( $sbl_errors as $error ) $newerrors .= ' ' . $error . "<br />\n"; $sbl_errors = $newerrors; } echo '<div id="login_error">' . apply_filters('login_errors', $sbl_errors) . "</div>\n"; } // login form echo '<form action="'; // Get url for CURRENT page echo "https://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; echo '" method="post" >'; ?> <p><label for="user_login"><?php _e('Username:') ?><br /><input name="log" value="<?php echo attribute_escape(stripslashes($_POST['user_login'])); ?>" class="mid" id="user_login" type="text" /></label></p> <p><label for="user_pass"><?php _e('Password:') ?><br /><input name="pwd" class="mid" id="user_pass" type="password" /></label></p> <p><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> <?php _e('Remember me'); ?></label></p> <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Login'); ?> »" /> <input type="hidden" name="sidebarLogin_posted" value="1" /> <input type="hidden" name="testcookie" value="1" /></p> </form> <?php // Output other links echo '<ul class="sidebarLogin_otherlinks">'; if (get_option('users_can_register')) : ?> <?php else : ?> <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> <?php endif; ?> </ul> <?php } // echo widget closing tag echo $after_widget; } // Register widget for use register_sidebar_widget(array('Sidebar Login', 'widgets'), 'widget_sidebarLogin'); } function widget_sidebarLogin_check() { // Are we doing a sidebar login action? if ($_POST['sidebarLogin_posted']) { $user_login = ''; $user_pass = ''; $using_cookie = FALSE; if ( $_POST ) { $user_login = $_POST['log']; $user_login = sanitize_user( $user_login ); $user_pass = $_POST['pwd']; $rememberme = $_POST['rememberme']; } else { $cookie_login = wp_get_cookie_login(); if ( ! empty($cookie_login) ) { $using_cookie = true; $user_login = $cookie_login['login']; $user_pass = $cookie_login['password']; } } do_action_ref_array('wp_authenticate', array(&$user_login, &$user_pass)); // If cookies are disabled we can't log in even with a valid user+pass if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) ) $errors['test_cookie'] = __('<strong>ERROR</strong>: WordPress requires Cookies but your browser does not support them or they are blocked.'); if ( $user_login && $user_pass && empty( $errors ) ) { $user = new WP_User(0, $user_login); if ( wp_login($user_login, $user_pass, $using_cookie) ) { if ( !$using_cookie ) wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); do_action('wp_login', $user_login); wp_safe_redirect("https://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']); exit(); } else { if ( $using_cookie ) $errors['expiredsession'] = __('Your session has expired.'); $errors['expiredsession'] = __('<strong>ERROR</strong>: Invalid user or password.'); } } if ( $_POST && empty( $user_login ) ) $errors['user_login'] = __('<strong>ERROR</strong>: The username field is empty.'); if ( $_POST && empty( $user_pass ) ) $errors['user_pass'] = __('<strong>ERROR</strong>: The password field is empty.'); $_POST['sbl_errors']=$errors; $_POST['user_login']=$user_login; } } // Run code and init add_action('widgets_init', 'widget_sidebarLogin_init'); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Duplicate this plugin…’ is closed to new replies.