MU Advanced: Issues and Discussion
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • September 08, 2010, 05:04:29 AM
Home Forums Contact Tags FAQ Links News Login Register
* *
Navigation Menu
Search

Random Quotes
No matter where you go, there you are.
- Buckaroo Bonzai
Pages: [1]   Go Down
  Print  
Author Topic: Help with coding  (Read 2284 times)
0 Members and 1 Guest are viewing this topic.
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« on: October 29, 2007, 05:18:42 PM »

I'm looking at upgrading the "post views" plugin that we use and wanted to bounce this off and see if anyone else had a better way of doing this.

We want to not count those visitors who are logged in and are a member of the blog in question.  I'm thinking about using the get_current_user() function and then doing a check against "can they write" or whatever it's called.  If true, then don't coung the visit.

Anyone else have a better method?

Here's the current code:

Code:
$should_count = false;
switch(intval($views_options['count'])) {
case 0:
$should_count = true;
break;
case 1:
if(empty($_COOKIE[USER_COOKIE])) {
$should_count = true;
}
break;
case 2:
if(intval($user_ID) > 0) {
$should_count = true;
}
break;
}

The cookie check won't work as they could be logged in but not a member of the blog in question.

Thanks,
-drmike

Logged

Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #1 on: October 29, 2007, 06:58:23 PM »

something like:

Code:
<?php
if ( !user_can('edit_posts') ) {
     
count_post_function();
}
?>

Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #2 on: October 29, 2007, 08:23:51 PM »

Yes, that's what I was talking about.

My question though was is there a better method or should I just use that one?
Logged

Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #3 on: October 29, 2007, 08:32:27 PM »

I would think my example would cut a bit of stuff out.

Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #4 on: October 29, 2007, 10:10:06 PM »

I would think my example would cut a bit of stuff out.

Agreed.  I was just wondering about other options.
Logged

Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #5 on: October 29, 2007, 11:22:54 PM »

Sure, there's lots of ways to do it.

The shorter, simpler it is, the more efficient it is though and you can't get much more simpler than that.

Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #6 on: November 04, 2007, 01:33:12 PM »

Actually I just found a function labeled is_user_member_of_blog built in.  It's in wpmu_functions.php in case anyone wants to look at it.
Logged

Tags:

Pages: [1]   Go Up
  Print  
 
Jump to:  


Login
 
 
Recent Posts
Recent Topics
No new topics.
Hot Tags
Whos Online
9 Guests, 0 Users
Home Forums Contact Tags FAQ Links News Login Register