Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-29-2012, 10:35 PM   #1
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Wordpress Gurus

Is it possible for a plugin to capture the text of a post someone has just entered in their posts area then perform an operation on that text before it gets placed into the database ?

Examples, taking the text and adding or removing elements, taking the text and adding or removing particular words or phrases ?
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 10:43 PM   #2
brentbacardi
Confirmed User
 
brentbacardi's Avatar
 
Industry Role:
Join Date: Nov 2009
Posts: 1,425
Pretty much anything on the web is possible if you have programming skills and unlimited time.

With that being said... Good Luck!
__________________
Go Fuck Yourself!
brentbacardi is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 10:47 PM   #3
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Sure, you can hook into the save_post action.
http://codex.wordpress.org/Plugin_AP...ence/save_post

For a list of tons of other hooks:
http://codex.wordpress.org/Plugin_API/Action_Reference
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 10:49 PM   #4
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Quote:
Originally Posted by Brujah View Post
Sure, you can hook into the save_post action.
http://codex.wordpress.org/Plugin_AP...ence/save_post

For a list of tons of other hooks:
http://codex.wordpress.org/Plugin_API/Action_Reference
Heh, I just glanced across the areas I could hook into, obviously I should have been more thorough. Thanks Brujah
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 10:54 PM   #5
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Hmm, content_save_pre might be closer to what you need according to this:
http://wordpress.stackexchange.com/q...-prior-to-save

WordPress StackExchange has filled out really well with a lot of great information about customizing WP.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 10:59 PM   #6
VenusBlogger
So Fucking Banned
 
Industry Role:
Join Date: Nov 2011
Posts: 1,540
yup, its possible.
VenusBlogger is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 11:03 PM   #7
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by VenusBlogger View Post
yup, its possible.
The latest forum idiot? Easy enough to ignore.
https://gfy.com/profile.php?do=addlis...gnore&u=162926
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-29-2012, 11:54 PM   #8
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Quote:
Originally Posted by Brujah View Post
Hmm, content_save_pre might be closer to what you need according to this:
http://wordpress.stackexchange.com/q...-prior-to-save

WordPress StackExchange has filled out really well with a lot of great information about customizing WP.
Thanks for this, you're spot on. I had only just come to that conclusion myself after reading the replies to this:

http://wordpress.stackexchange.com/q...re-it-is-saved

I'm well on the way now. I hardly ever write any plugins myself but I just needed to whip something up for testing an idea real quick

thanks for the responses
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 01:37 AM   #9
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,384
:2cents

Quote:
Originally Posted by AdultKing View Post
Is it possible for a plugin to capture the text of a post someone has just entered in their posts area then perform an operation on that text before it gets placed into the database ?

Examples, taking the text and adding or removing elements, taking the text and adding or removing particular words or phrases ?
Easily. I just made some custom plugin which attaches a featured image to every new post basing on the keywords in its title.
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 01:45 AM   #10
Paul Markham
Too old to care
 
Paul Markham's Avatar
 
Industry Role:
Join Date: Jun 2001
Location: On the sofa, watching TV or doing my jigsaws.
Posts: 52,943
Now you can add this info to your blog to teach newbies. LOL
Paul Markham is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 02:03 AM   #11
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Quote:
Originally Posted by CyberSEO View Post
Easily. I just made some custom plugin which attaches a featured image to every new post basing on the keywords in its title.
Yep, took me 2 minutes once I found the right hook.

Quote:
Originally Posted by Paul Markham
Now you can add this info to your blog to teach newbies. LOL
Pity you didn't learn enough to fund your own retirement, instead leaching off the British taxpayers who did.
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 02:27 AM   #12
AllAboutCams
Femcams.com
 
AllAboutCams's Avatar
 
Industry Role:
Join Date: Jul 2011
Location: bjcam.com
Posts: 12,221
Quote:
Originally Posted by Brujah View Post
The latest forum idiot? Easy enough to ignore.
https://gfy.com/profile.php?do=addlis...gnore&u=162926
Thank you
AllAboutCams is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 05:52 AM   #13
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
you want wp_insert_post_data

i did this, so when you publish a post it took you back a year ;)

Code:
function back_to_the_future($data,$postarr) {
    	$format = 'Y-m-d H:i:s';
	$old_date = $data['post_date'];
	$old_date_gmt = $data['post_date_gmt'];
    	$new_date = date($format, strtotime('-1 year',strtotime($old_date)));
    	$new_date_gmt = date( $format, strtotime('-1 year',strtotime($old_date_gmt)));
	$data['post_date'] = $new_date;
	$data['post_date_gmt'] = $new_date_gmt;
    	return $data; 
} 

add_filter('wp_insert_post_data','back_to_the_future',99,2);
in your case you would want to use post_content

like so

Code:
function change_post_content($data,$postarr) {
        $post_content = strip_tags($data['post_content']);
	$data['post_post_content'] = $post_content;
    	return $data; 
} 

add_filter('wp_insert_post_data','change_post_content',99,2);
which would strip html tags from post content, etc.

this will get you started.
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 06:12 AM   #14
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Hey, thanks heaps for that fris.
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 06:28 AM   #15
AdultKing
Raise Your Weapon
 
AdultKing's Avatar
 
Industry Role:
Join Date: Jun 2003
Location: Outback Australia
Posts: 15,601
Just for anyone else who is interested in the solution here, based on fris' excellent example this is changing the post content, you could replace ucwords with any function or series of functions to modify your post content.

Code:
<?php
/*
Plugin Name: Your own Plugin
Plugin URI: http://someurl.com
Description: Converts the fist letter of every word to upper case.
Author: Your Name
Version: 1.5
*/

function change_content($data,$postarr) {
    	$old_content = $data['post_content'];
    	$new_content = ucwords($old_content);
    	$data['post_content'] = $new_content;
    	return $data; 
} 

add_filter('wp_insert_post_data','change_content',99,2);


?>
AdultKing is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-30-2012, 07:50 AM   #16
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
glad it worked out ;)
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.