Not logged in. · Lost password · Registration disabled
Forum: Overview Questions / Fragen RSS
Edit post shows No as default send notification
jeffsherk #1
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Edit post shows No as default send notification
Whenever I go to edit a new post that has been submitted, the default setting reads (on the post edit page):

Send notification when publishing? NO

How do I set this to default to YES? I don't see it as an option in the settings menu.

Thanks (v1.28)
Morty (Administrator) #2
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Well this is intended. Or do you want to send a notification each time you edit a post? *thinking* Changing it to "NO (mails were already sent)" might be better, though.
jeffsherk #3
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Just to explain what I'm doing... I use another plugin called TDO Mini Forms, which allows non-registered users to submit a post without registering. It then needs to be moderated/edited before it is posted. Typically, it will be edited, published and then left alone for a very long time. Since I have different people doing this editing/publishing, they don't always remember to change the Send Post Notification to Yes, so I have to go back in and change it to yes and resave it to get it sent out to everybody. So for my purposes, a default of Yes would be better.

I suppose I can change the default in the code from No to Yes? Which file would I find this in to make the change?

Thanks
Morty (Administrator) #4
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Are the settings set to yes?
jeffsherk #5
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Which settings? The When To Send settings?

Send Normal posts by default? Yes
Send Private posts by default? No
Send Pages by default? No

I was thinking that with one of these settings above set to Yes, that Send Notification When Publishing should default to Yes, but it always shows up as No.
Morty (Administrator) #6
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Hmm yes. That's because it thinks that it's an old post from before Post Notification. I'll have to think about this...
jeffsherk #7
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Okay, I see that there is something going behind the scenes...

When I create a new post from within the wp admin, it defaults to Default with two more options of Yes or No. This works fine...

If I save that post as a draft, and then reopen it for editing, it defaults to Send Mails In Queue with two more options of Yes or No. This works fine as well..

When a new post is submitted thru the TDO Mini Forms plugin, it is saved as a draft, and the first time you go to edit/moderate it, it defaults to No with only one other option of Yes (there is no option for Default or Send Mails In Queue).

So question is, what "flags" are you using to determine the options available in the drop down box for Send Notification When Publishing?
jeffsherk #8
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
I was quickly looking thru the code in post_notification.php and around line 100...

$textyes = __('Yes', 'post_notification');
$textdef = __('Default', 'post_notification');
$default = false;

if(0 != $post_ID){ //We've got an ID.
  $status= $wpdb->get_var("SELECT notification_sent FROM $t_posts WHERE post_ID = '$post_ID'");
  if(isset($status)){ //It's in the DB
   if($status >= 0){ //It will be sent in the future
    $default = true;
    $textdef = __('Send Mails in queue.', 'post_notification');
    } else { //It has been sent or is not being sent.
      $sendN = 'selected="selected"';
      if($status != -2) { //If it's -2 nothing has been sent.
        $textyes = __('Resend', 'post_notification');
      }
    }
  } else { //This one has been written bevore PN was installed.
    $sendN = 'selected="selected"';
  }
} else {
  $default = true;
}

It looks like the isset($status) is checking for:
  (1) Is it in the DB? No? Then set default to to NO
  (2) Has it been sent or is it not being sent? Yes? Then set default to NO

Can you explain a little more what this $status flag is?

Is it generated by WP, or is it exclusive to Post Notification?

Thanks

P.S.- I can see that it would be easy for me to change the default from No to Yes in the code, but I would prefer it to default to No AFTER it's actually been published.
jeffsherk #9
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Solved... I think..
Okay around line 115 is the following line...
  } else { //This one has been written bevore PN was installed.
     $sendN = 'selected="selected"';

This is marking all draft/unpublished posts submitted thru TDO Mini Forms to the default of No.

If I change the line from $sendN to $sendY like this...
  } else { //This one has been written bevore PN was installed.
     $sendY = 'selected="selected"';

then the posts submitted thru TDO Mini Forms show up with the default of Yes when you go to edit it the first time (which is what I want), and once published it will show up with a default as No (which is good as well).

I don't think this is a bug, it just appears that you decided to set the default as NO for any posts saved (but not published) prior to PN being installed.

Thanks
Morty (Administrator) #10
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Quote by jeffsherk:
I don't think this is a bug, it just appears that you decided to set the default as NO for any posts saved (but not published) prior to PN being installed.

That's right. Otherwise it might happen that a notification is sent out for an old post, in which you change a typo. The alternative is, that all posts are added to the database on installation.
Till now I tried to keep the database as small as possible. But I think that might change in the next version as I'll do some redesign.
jeffsherk #11
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: solved
The code change above will work for me for now. It was a simple mod.

I'm wondering though, why posts submitted thru TDO Mini Forms show up as "old" (prior to PN installed), when they are new? Is the $status variable something that is set by PN, and therefore it does not get set when TDO Mini Forms submits a post?

Thanks
Morty (Administrator) #12
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Basically it works the following way:

If you have a new post, there is no ID assigned to it ($post_ID != 0). If so PN takes the dafault value. Otherwise it checks the PN-Database for that Id. If it finds an entry it takes that value. If PN finds no entry it assumes that the Post was written before PN was installed.

The Problem with TDO Mini Forms is, that the post is added to the WP database, but not to the PN database, and PN therefore thinks, that the post was written before PN was installed. I might add another hook, though, to decide what to do with Posts, that are not added by the "default" method. (This also applies to posting per Mail.)
jeffsherk #13
Member since Nov 2007 · 37 posts
Group memberships: Mitglieder
Show profile · Link to this post
I suppose the biggest problem with being the author of a plugin, is that everybody wants your plugin to do everything THEY want, the way THEY want it done!!! Evertime you add one new feature, you end up adding two more features to the to-do list!

I appreciate the time and energy involved in writing and updating the plugin, and also appreciate your replies.

Thanks again.
Morty (Administrator) #14
User title: Author
Member since Jun 2007 · 928 posts
Group memberships: Administratoren, Mitglieder
Show profile · Link to this post
Adding features is a problem, indeed. But I learned a lot writing this plugin. So it's not too bad... :-) Also it's good reputation. ;-)

I added it feature request: http://pn.xn--strbe-mva.de/forum.php?req=thread&postid…
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum