Sivel.net Forum

Support forum for Sivel.net

You are not logged in.

Announcement

The Sivel.net support forums have been shutdown in favor of the WordPress.org Support Forums. This forum will remain online in a read only state for archival purposes. Please use the following links to navigate to the WordPress.org Support Forum for each specific plugin.

#1 2008-10-23 12:24:21

penfil
New member
Registered: 2008-10-23
Posts: 6

Can't restrict access to static pages that use other plugins - ex:WPG2

Hey there, great plugin! I love it!

One question I have is in regards to restricting access to pages that are used by other plugins like WPG2 and Event Calendar.

I think the reason why they are unaffected by your plug-in is because they override something on the page and perhaps that is an issue? Do you think there is a way around it?

I am working on a site for my boss and she wants people to be logged-in in order to view her Event's Calendar and Gallery...

Thanks!

Offline

 

#2 2008-10-24 09:23:24

mdmartz
Administrator
Registered: 2008-08-16
Posts: 230
Website

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

Try downloading the development version from http://downloads.wordpress.org/plugin/pagerestrict.zip

Let me know if it solves the problem.

Offline

 

#3 2008-10-25 23:25:32

penfil
New member
Registered: 2008-10-23
Posts: 6

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

Thanks for getting back to me so quickly. I tried the development version as you suggested, but it still is not working. I tested it out on a page that is not affected by a different plugin (ex. the about page) and it works, just doesn't seem to work with pages affected by plugins like WPG2.

Here's a link to the blog. The page links are on the left. The only one that is supposed to be restricted is "Gallery".

Thanks again for looking in to this. My boss will be quite pleased once it is all worked out.

Offline

 

#4 2008-10-31 09:22:27

penfil
New member
Registered: 2008-10-23
Posts: 6

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

Just a thought... the WPG2's Gallery Page allows use of custom headers and footers to allow modification so that the layout would fit more with the current theme...

Is there some certain function in your Page Restrict plugin that I can call in the custom header before the page is called that would allow compatibility? Or perhaps I would need to place the function within the WPG2 plugin somewhere...?

Offline

 

#5 2008-10-31 10:55:30

penfil
New member
Registered: 2008-10-23
Posts: 6

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

OK, I have a simple Hack that seems to work... Here's what I did...

I looked through the code in both plugins (Page Restrict and WPG2). I focused on the PR function: pr_page_restrict and noticed that's the function I needed... In the WPG2 file: "wpg2template.inc" around line 129 there is the following statement:

Code:

echo $g2data['bodyHtml'];     //Display the gallery content

So I modified the code to be the following:

Code:

if (pr_get_opt('version')) {
    echo pr_page_restrict($g2data['bodyHtml']);
}
else {
    echo $g2data['bodyHtml'];     //Display the gallery content
}

Then I modified the pr_page_restrict function in pagerestrict.php to include

Code:

<div class="pr_box" id="pr_box">

at the beginning of the output and of course

Code:

</div>

at the end of the output (this is so I could modify the stylesheet to help the display fit with my theme).

It works... Not sure if this is the best approach, but it works...

Any thoughts?

Last edited by penfil (2008-10-31 10:56:10)

Offline

 

#6 2008-11-30 12:30:26

gsharp
New member
Registered: 2008-11-30
Posts: 1

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

I believe my problem is the same issue with this posting.

This plug-in does not seem to work with plugin Profiler.  I tried copying the hack posted but it is not working.

The profile directory page is not being replaced by the login required page even though its selected in the Page Restrict Admin.

What's happening is that its displaying the page configured as restricted in Admin page AND the "login page" on the same page for both the online directory page and user profile page.

I am thinking its because of the extra "current_page_item" value" (this is from the view source):

Code:

<li class="page_item page-item-196 current_page_item"><a href="http://marikinahighschoolalumni.com/blog/?page_id=196" title="Alumnis">Alumnis</a></li>

This is how a working page looks like from view source:

Code:

<li class="page_item page-item-258"><a href="http://marikinahighschoolalumni.com/blog/?page_id=258" title="Featured">Featured</a></li>

WP version = 2.6.3
Blog page issue = http://marikinahighschoolalumni.com/blog/?page_id=196
and http://marikinahighschoolalumni.com/blo … er=tester1

Offline

 

#7 2008-12-01 10:11:20

penfil
New member
Registered: 2008-10-23
Posts: 6

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

@gsharp - It looks like you need to filter the output from your Profiler plugin through the PageRestrict plugin.

I haven't tested this as I have not installed the Profiler plugin... But I think this is what you need to do...

In the file: "profiler.php" (from your profiler plugin) you see the following 3 lines of code: (lines 615-617)

Code:

    echo '<div class="pfdirectory">';
    echo $output;
    echo '</div>';

These are in the function that displays the user directory. Try changing those lines to the following:

Code:

    echo '<div class="pfdirectory">';
    if (pr_get_opt('version')) {
            echo pr_page_restrict($output);    //Pass user directory through pagerestrict filter
    }
    else {
            echo $output;     //Display the user directory
    }    
    echo '</div>';

That should do the trick for what you are trying to do...

To cover some of the things you mentioned:

The profile directory page is not being replaced by the login required page even though its selected in the Page Restrict Admin.

That is because the profiler plugin is (without the hack) bypassing the pagerestrict actions. Since the page has some code in it (you can see it by opening the page in edit view in your admin panel) that calls the profiler plugin first before the pagerestrict plugin.

What's happening is that its displaying the page configured as restricted in Admin page AND the "login page" on the same page for both the online directory page and user profile page.

This happens because the profiler plugin bypasses the pagerestrict plugin for that page so the profiler content is still being displayed, then the pagerestrict plugin kicks in and recognizes that the page is restricted and posts the login form... That's why the hack is needed to filter the profiler output through the pagerestrict.

I am thinking its because of the extra "current_page_item" value"

The restriction has nothing to do with CSS and does not appear to be processed through JavaScript or by manipulating the DOM after the page is processed... So the ID, CLASS, or NAME of an element should not matter in this case.

Last edited by penfil (2008-12-01 10:19:24)

Offline

 

#8 2008-12-12 16:30:54

msturm
New member
Registered: 2008-12-12
Posts: 3

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

Thanks penfil!

I had the same problem as gsharp so I changed the php code as you suggested. It almost worked perfectly. It does hide the members directory but displays the PageRestrict restriction message twice separated by the page indicator <<1>> Do you think that has to do with the php code on what is now line 624-632 - see below. Thanks for you help!

    pf_directory_pagination($lastpage);
}

function pf_directory_pagination($lastpage)
{
    $page = round($_GET['page']);
    if($page < 1)
        $page = 1;
    $character = pf_directorypagi_url_char();

Offline

 

#9 2008-12-14 03:32:16

penfil
New member
Registered: 2008-10-23
Posts: 6

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

msturm wrote:

Thanks penfil!

I had the same problem as gsharp so I changed the php code as you suggested. It almost worked perfectly. It does hide the members directory but displays the PageRestrict restriction message twice separated by the page indicator <<1>> Do you think that has to do with the php code on what is now line 624-632 - see below. Thanks for you help!

    pf_directory_pagination($lastpage);
}

function pf_directory_pagination($lastpage)
{
    $page = round($_GET['page']);
    if($page < 1)
        $page = 1;
    $character = pf_directorypagi_url_char();

Hey msturm,

To answer your question, yes, essentially the issue is with that last line of the function making  a call to "pf_directory_pagination($lastpage)". I installed the profiler plug-in just because this was making me curious... Here's what I did to get it to work:

In "profiler.php" starting at line 615 to the end of the function (should be line 629) here is what I now have...

Code:

    echo '<div class="pfdirectory">';
    $show_pagination = 1;
    if (pr_get_opt('version')) {
            if (pr_page_restrict($output) == $output)
                echo $output;    // if they are the same then display the user directory else do not
            else
                $show_pagination = 0; // turn off pagination
    }
    else {
            echo $output;     //Display the user directory
    }    
    echo '</div>';
    
    if ($show_pagination == 1)
        pf_directory_pagination($lastpage);

I added some comments to help explain what is going on... It should be clear enough. Basically I added a variable called $show_pagination (bet you can't guess what that's for!) and set it to 1 (true). I change that to 0 (false) only if the results from the pr_page_restrict($output) call are different from the original $output (meaning that the PageRestrict was needed).

Also, instead of simply doing: echo pr_page_restrict($output) // which caused the double login to be displayed
I put in a conditional to catch it if the return value was different.

It's like 4:30am here so you'll have to forgive me if my writing is a bit sloppy.

I hope this is clear enough. I tested it out and it works for me.

Last edited by penfil (2008-12-14 03:36:23)

Offline

 

#10 2008-12-15 09:44:40

msturm
New member
Registered: 2008-12-12
Posts: 3

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

Thanks again! Your code worked! I hope it still will with the new version that seems to be released soon. Great plugin!

Offline

 

#11 2009-08-26 20:35:53

gmcle454
New member
Registered: 2009-08-26
Posts: 1

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

I'm having the same problem. I did try the development version, but that didn't work. Is there a work-around that doesn't involve modifying the other plugin (in my case a basic forum)? I'm concerned that an update to the other plugin will break the page restriction.

what can I do?

Offline

 

#12 2009-08-27 08:04:49

mdmartz
Administrator
Registered: 2008-08-16
Posts: 230
Website

Re: Can't restrict access to static pages that use other plugins - ex:WPG2

The problem is that some plugin authors don't know what they are doing and are echoing when using a filter.  Which means that other plugins cannot filter their output.  Use another plugin or have the offending plugin author fix their issues.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB