Hallo Leute, ich habe mal wieder ein Problem und die sufu hat nicht wirklich geholfen.
Ich benutze das widget sidebarlogin. Seit dem ich das installiert habe, kommt man nach dem Einloggen erst auf den Tellerrand und nicht auf die Startseite. Eine Änderung der Sidebar.php hat nicht funktioniert.
Ich weiß nicht wo ich das ändern muss. :oops:
PHP
<?php
/*
Plugin Name: Sidebar Login
Description: Adds a sidebar widget to let users login
Author: Mike Jolley, [EMAIL="jolley_small@tesco.net"]jolley_small@tesco.net[/EMAIL]
Version: 1.0
Author URI: [URL="http://blue-anvil.com"]Blue Anvil Journal[/URL]
*/
function widget_sidebarLogin_init() {
if ( !function_exists('register_sidebar_widget') )
return;
function widget_sidebarLogin($args) {
extract($args);
// Get user info
global $user_level,$user_identity,$user_ID;
get_currentuserinfo();
if ('' != $user_ID) {
// User is logged in
echo $before_widget . $before_title . "Willkommen ".$user_identity . $after_title;
echo '
<ul class="pagenav">
<li class="page_item"><a href="'.get_bloginfo('wpurl').'/wp-admin">Site-Admin</a></li>
<li class="page_item"><a href="?page_id=53">Interner Bereich</a></li>
<li class="page_item"><a href="'.get_bloginfo('wpurl').'/wp-login.php?action=logout&redirect_to=http://'.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'].'">Logout</a></li>
</ul>
';
} else {
// User is NOT logged in!!!
echo $before_widget . $before_title . "Login" . $after_title;
// Show any errors
//session_start();
$errors = array();
$errors = unserialize($_SESSION['sidebarLogin_errors']);
$_SESSION['sidebarLogin_errors'] = "";
if ( !empty( $errors ) ) {
if ( is_array( $errors ) ) {
$newerrors = "\n";
foreach ( $errors as $error ) $newerrors .= ' ' . $error . "<br />\n";
$errors = $newerrors;
}
echo '<div class="errors">' .$errors . "</div>\n";
echo "<p><strong>Note:</strong> You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use this site.</p>";
}
// login form
echo '<form action="';
// Get url for wp_login page
echo get_bloginfo("siteurl")."/wp-login.php";
echo '" method="post" >';
?>
<p><label for="user_login"><?php _e('Username:') ?><br/><input name="log" 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="redirect_to" value="<?php echo "http://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; ?>" />
<input type="hidden" name="sidebarLogin_posted" value="1" /></p>
</form>
<?php
// Output other links
echo '<ul class="sidebarLogin_otherlinks">';
if (get_option('users_can_register')) :
?>
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php _e('Register') ?></a></li>
<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 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_geterrrors() {
global $errors, $error, $wp_locale;
// GETS ERRORS AND REDIRECTS BACK IF ANY FOUND
if ($_REQUEST['sidebarLogin_posted']==1) {
if ( isset( $_REQUEST['redirect_to'] ) )
$redirect_to = $_REQUEST['redirect_to'];
// Save error messages for later!
//session_start();
// Incase a plugin uses $error rather than the $errors array
$errors2=array();
$errors2=$errors;
if ( !empty( $error ) ) {
$errors2['error'] = $error;
}
if ( !empty( $errors2 ) ) {
if ( is_array( $errors2 ) ) {
$newerrors = "\n";
foreach ( $errors2 as $err ) $newerrors .= ' ' . $err . "<br />\n";
$errors2 = $newerrors;
}
}
$_SESSION['sidebarLogin_errors'] = serialize(apply_filters('login_errors', $errors2));
// Redirect back
wp_redirect($redirect_to);
exit();
ob_end_flush();
}
}
function widget_sidebarLogin_start() {
if ($_REQUEST['sidebarLogin_posted']==1) {
ob_start();
session_start();
}
}
function widget_sidebarLogin_hstart() {
session_start();
}
// Run code and init
add_action('widgets_init', 'widget_sidebarLogin_init');
// Add code to save errors to session var
add_action('login_head', 'widget_sidebarLogin_geterrrors');
add_action('wp_authenticate', 'widget_sidebarLogin_start');
add_action('init', 'widget_sidebarLogin_hstart');
?>
Alles anzeigen
Muss ich das im Widget ändern? Die Sidebar.php reagiert ja nicht mehr wenn widgets installiert sind.
Hoffe ihr könnt mir helfen. Bin ja ein newbie in wp. :oops: