View previous topic :: View next topic |
Author |
Message |
yuch
Joined: 27 Feb 2003 Posts: 13 Location: Singapore
|
Posted: Thu Mar 20, 2003 9:18 am Post subject: filter functions help |
|
|
I am currently trying to make some of my posts private. I read the thread on filter functions here.
http://tidakada.com/board/viewtopic.php?t=1560&highlight=level+0+cannot+view
And I implemented the exact same code below. I put this code in my index.php, on line 2, before the "include ("blog.header.php");" line.
Code: |
<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=1; include ("blog.header.php"); ?>
<?php
function b2_private_entry($string) {
$password = 'jesusatemyballs';
if (stristr($string, '<private />')) {
if (trim($_POST['b2_password']) != $password) {
$form = 'This is a private entry.<br />To view private entries on this website, please enter the password in the field below:<br /><form method="POST"><input type="password" name="b2_password" /><input type="submit" value="OK" /></form>';
return $form;
}
}
return preg_replace('#\<private \/\>#is', '', $string);
}
add_filter('the_content', 'b2_private_entry');
?> |
When I make private posts, I do this from my b2edit. Quote: | <private />TESTING. Private post.</private> |
However, when I enter the password on my site, it does not display the private post. It simply refreshes and gives me the same page with the password form dialogue again.
I am using the "proper page refresh for MSIE" hack (the one michel posted on the main cafelog page...could this be the problem?), and b2 version 0.6.1. What exactly does preg_replace do? The </private> tag was automatically added in for me, I didn't type it in my post.
Can someone tell me what is wrong?? Sorry, but I am absolutely clueless abt PHP...
If it helps, my site is at [url]yuch.ionichost.com[/url] _________________ yuch ^^ |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Thu Mar 20, 2003 1:19 pm Post subject: |
|
|
hmm maybe you can try $HTTP_POST_VARS['b2_password'] instead of $_POST['b2_password'] _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
yuch
Joined: 27 Feb 2003 Posts: 13 Location: Singapore
|
Posted: Thu Mar 20, 2003 8:17 pm Post subject: |
|
|
nope...still doesn't work... _________________ yuch ^^ |
|
Back to top |
|
 |
yuch
Joined: 27 Feb 2003 Posts: 13 Location: Singapore
|
Posted: Thu Mar 20, 2003 9:25 pm Post subject: |
|
|
i think there's something wrong with the form input...
but still can't get it to work... ...frustrating... _________________ yuch ^^ |
|
Back to top |
|
 |
Gadget Girl
Joined: 25 Jan 2002 Posts: 305 Location: Virginia
|
Posted: Tue Apr 08, 2003 12:44 pm Post subject: |
|
|
Hi,
I just tested this and only put <private /> once in the entry. Worked for me.
Sara |
|
Back to top |
|
 |
yuch
Joined: 27 Feb 2003 Posts: 13 Location: Singapore
|
Posted: Tue Apr 08, 2003 1:09 pm Post subject: |
|
|
oh, i solved it finally...i put the HTTP_POST thing as a global variable (i guess that's bad coding but if it works, it works ) and it worked... _________________ yuch ^^ |
|
Back to top |
|
 |
Gadget Girl
Joined: 25 Jan 2002 Posts: 305 Location: Virginia
|
Posted: Tue Apr 08, 2003 1:41 pm Post subject: |
|
|
Glad to hear it!  |
|
Back to top |
|
 |
Gadget Girl
Joined: 25 Jan 2002 Posts: 305 Location: Virginia
|
Posted: Sat Apr 12, 2003 4:26 pm Post subject: |
|
|
Hi,
Can anyone please help me? I want to use the private entries mod, but, I can't figure out the .RSS and how to hide the title.
I apologize if there is a thread with this in it already, I did search. Please point me in the right direction, thanks!
Sara  |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Sat Apr 12, 2003 4:59 pm Post subject: |
|
|
I've implemented it but it's not hackable... the code is too complex. See http://frcooper.com/devblog/ |
|
Back to top |
|
 |
Gadget Girl
Joined: 25 Jan 2002 Posts: 305 Location: Virginia
|
Posted: Sat Apr 12, 2003 5:05 pm Post subject: |
|
|
I appreciate the link, but, did you have code on there I missed? Your blog entries go across the blog and under the sidebar.
You may want to fix that by declaring a width in your blog entries .CSS.
I was actually looking for the code to hide the private entries in .RSS and the title in .RSS and on the blog. You can still see your title on your .RSS feed, did you know that?
Sara |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Sat Apr 12, 2003 5:30 pm Post subject: |
|
|
The code is in the cvs.
IE has the bug, not the CSS. |
|
Back to top |
|
 |
Gadget Girl
Joined: 25 Jan 2002 Posts: 305 Location: Virginia
|
Posted: Sat Apr 12, 2003 6:05 pm Post subject: |
|
|
I looked in the CVS and found it for the .RSS feed and .rss2, but the entire entry is still showing.
Thanks anyhow.
Sara |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Sat Apr 12, 2003 8:08 pm Post subject: |
|
|
See all the commits marked "added support for protected entries"? Those are all the files needed to fix it everywhere... |
|
Back to top |
|
 |
|