<div >
<p >一、添加一个存储投稿者邮箱的自定义栏目
<p > 打开wordpress添加投稿功能,下面我们将对这篇文章中的代码进行修改。在第二段代码第78行插入以下代码:
<pre Bitstream Vera Sans Mono","CourIEr New",CourIEr,monospace; word-wrap: break-word; white-space: pre-wrap; ORPHANS: 2; LETTER-SPACING: normal; color: rgb(0,0); border-top: rgb(187,187) 1px dashed; border-RIGHT: rgb(187,187) 1px dashed; WORD-SPACING: 0px; padding-top: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-wIDth: 0px" name="code"><span >// 其中 ludou_tougao_email 是自定义栏目的名称
<span >addpostMeta<span >($status<span >, <span >'ludou_tougao_email'<span >, $email<span >, TRUE<span >);
<p >二、添加提醒功能PHP代码
<p > 在主题目录下的functions.PHP添加以下PHP代码(将以下代码中的露兜博客名称和URL改成你自己的):
<pre name="code"><span >function <span >tougao_notify<span >($mypost<span >) <span >{
$email <span >= <span >get_post_meta<span >($mypost<span >->ID<span >,255); @R_403_6837@-WEIGHT: normal" >"ludou_tougao_email"<span >, <span >true<span >);
<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(165,42); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >if<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">( <span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">!<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(0,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: b<a href="https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>d" >empty<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">($email<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">) <span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">) <span >{ <span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >// 以下是<a href="https://www.jb51.cc/tag/youjian/" target="_blank" >邮件</a><a href="https://www.jb51.cc/tag/biaoti/" target="_blank" >标题</a> $subject <span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">= <span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,255); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >'您在露兜<a href="https://www.jb51.cc/tag/boke/" target="_blank" >博客</a>的投稿已<a href="https://m.jb51.cc/tag/fabu/" target="_blank" >发布</a>'<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">; <span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >// 以下是<a href="https://www.jb51.cc/tag/youjian/" target="_blank" >邮件</a><a href="https://www.jb51.cc/tag/neirong/" target="_blank" >内容</a> $message <span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">= <span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,255); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >'
<span >
露兜博客 提醒您: 您投递的文章 ' <span >. $mypost<span >->postTitle <span >. <span >' 已发布
<span >
<span >
您可以点击以下链接查看具体内容:
<span > <a href="' <span >. <span >get_permalink<span >( $mypost<span >->ID <span >) <span >. <span >'">点此查看完整內容
<span >
===================================================================
<span >
感谢您对 露兜博客 的关注和支持
<span >
该信件由系统自动发出,请勿回复,谢谢.
'<span >; <span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(0,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: b<a href="https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>d" >add_filter<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">(<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,255); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >'wp_mail_content_type'<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">,<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(0,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: b<a href="https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>d" >create_function<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">(<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(255,255); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >''<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">,255); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal" >'return "text/<a href="https://m.jb51.cc/tag/HTML/" target="_blank" >HTML</a>";'<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">)); @<span https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-STYLE: <a href="https://www.jb51.cc/tag/nor/" target="_blank" >nor</a>mal; <a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>: rgb(0,0); @R_<a href="https://www.jb51.cc/tag/403/" target="_blank" >403</a>_6837@-WEIGHT: b<a href="https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>d" >wp_mail<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">( $email<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">, $subject<span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">, $message <span https://m.jb51.cc/tag/ol/" target="_blank" >ol</a>">);<span >}
<span >}
<span >// 当投稿的文章从草稿状态变更到已发布时,给投稿者发提醒邮件
<span >add_action<span >(<span >'draft_to_publish'<span >,255); @R_403_6837@-WEIGHT: normal" >'tougao_notify'<span >,255); @R_403_6837@-WEIGHT: normal" >6<span >);
<p > 以上功能需要你的服务器支持mail函数。
以上是内存溢出为你收集整理的WordPress投稿功能添加邮件提醒功能的方法全部内容,希望文章能够帮你解决WordPress投稿功能添加邮件提醒功能的方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)