WordPress

WordPress无法登陆后台,输入用户名密码之后仍旧返回登陆界面,死循环的问题.

症状:无法登陆wordpress后台,输入用户名密码之后仍旧返回登陆界面.当然以前是好的,换任何浏览器和操作系统都一样,并且在别人电脑上是没问题的.

解决方法:打开文件”/wp-includes/pluggable.php”,修改”wp_set_auth_cookie”函数.将两处(第一处在666行左右,第二处就在后面几行,基本上改第一处就可以了,wordpress 2.9.2;wordpress 3.0 在691行)

setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);

修改为

setcookie($auth_cookie_name, $auth_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure, true);

后记:主要就是更改cookie的作用目录,由原来的”/wp-admin”变成根目录”/”.问题大概是由于无法跨目录读取用户的cookie导致的(参见pluggable.php中的函数wp_parse_auth_cookie).

Comment Mail Notify

安装步骤:在下面三種方式, 選擇你想用的代碼, copy 到主題的 functions.php 的 <?php ….. ?> 區域內.

一、有勾選欄, 由訪客決定是否要回應郵件通知:

/* comment_mail_notify v1.0 by willin kan. (有勾選欄, 由訪客決定) */
function comment_mail_notify($comment_id) {
  $admin_notify = '1'; // admin 要不要收回覆通知 ( '1'=要 ; '0'=不要 )
  $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail.
  $comment = get_comment($comment_id);
  $comment_author_email = trim($comment->comment_author_email);
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  global $wpdb;
  if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '')
    $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;");
  if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1'))
    $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'");
  $notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0';
  $spam_confirmed = $comment->comment_approved;
  if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') {
    $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 發出點, no-reply 可改為可用的 e-mail.
    $to = trim(get_comment($parent_id)->comment_author_email);
    $subject = '您在 [' . get_option("blogname") . '] 的留言有了回應';
    $message = '
' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . nl2br(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 給您的回應:' . nl2br($comment->comment_content) . ' 您可以點擊 查看回應完整內容 歡迎再度光臨 ' . get_option('blogname') . ' (此郵件由系統自動發出, 請勿回覆.)
'; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, '
' , $subject, $message; // for testing } } add_action('comment_post', 'comment_mail_notify'); /* 自動加勾選欄 */ function add_checkbox() { echo ' '; } add_action('comment_form', 'add_checkbox'); // -- END ----------------------------------------

二、無勾選欄, 由管理者決定在什麼條件下發郵件:

/* comment_mail_notify v1.0 by willin kan. (無勾選欄) */
function comment_mail_notify($comment_id) {
  $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail.
  $comment = get_comment($comment_id);
  $comment_author_email = trim($comment->comment_author_email);
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  $to = $parent_id ? trim(get_comment($parent_id)->comment_author_email) : '';
  $spam_confirmed = $comment->comment_approved;
  if (($parent_id != '') && ($spam_confirmed != 'spam') && ($to != $admin_email) && ($comment_author_email == $admin_email)) {
    /* 上面的判斷式,決定發出郵件的必要條件:
    ($parent_id != '') && ($spam_confirmed != 'spam'): 回覆的, 而且不是 spam 才可發, 必需!!
    ($to != $admin_email) : 不發給 admin.
    ($comment_author_email == $admin_email) : 只有 admin 的回覆才可發.
    可視個人需求修改以上條件.
    */
    $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 發出點, no-reply 可改為可用的 e-mail.
    $subject = '您在 [' . get_option("blogname") . '] 的留言有了回應';
    $message = '
' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . nl2br(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 給您的回應:' . nl2br($comment->comment_content) . ' 您可以點擊 查看回應完整內容 歡迎再度光臨 ' . get_option('blogname') . ' (此郵件由系統自動發出, 請勿回覆.)
'; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, '
' , $subject, $message; // for testing } } add_action('comment_post', 'comment_mail_notify'); // -- END ----------------------------------------

三、所有回覆都發郵件:

/* comment_mail_notify v1.0 by willin kan. (所有回覆都發郵件) */
function comment_mail_notify($comment_id) {
  $comment = get_comment($comment_id);
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  $spam_confirmed = $comment->comment_approved;
  if (($parent_id != '') && ($spam_confirmed != 'spam')) {
    $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); //e-mail 發出點, no-reply 可改為可用的 e-mail.
    $to = trim(get_comment($parent_id)->comment_author_email);
    $subject = '您在 [' . get_option("blogname") . '] 的留言有了回應';
    $message = '
' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . nl2br(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 給您的回應:' . nl2br($comment->comment_content) . ' 您可以點擊 查看回應完整內容 歡迎再度光臨 ' . get_option('blogname') . ' (此郵件由系統自動發出, 請勿回覆.)
'; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, '
' , $subject, $message; // for testing } } add_action('comment_post', 'comment_mail_notify'); // -- END ----------------------------------------

WordPress》上有 2 条评论

  1. Nirvanacs:
    您好,无意中进入这一网页,我是一名高中数学老师,刚开始辅导竞赛,您对资料太好了,向您的无私精神致敬!!
    秋安!
    2011.10.16

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>