I’m going to shift to ‘Extensions’- because you’re right, that’s the way to go on this one. I suspect there are a number of existing extensions you could riff off of. I’ve got one open- uses the SAEF, but I suspect it’s just a matter of changing the hook. The gist is:
<?php
/*
=========================================================
This Extension is intended for use with ExpressionEngine.
ExpressionEngine is Copyright (c) 2003 pMachine, Inc.
http://www.pmachine.com/
=========================================================
by da cow
========================================================
*/
if ( ! defined('EXT'))
{
exit('Invalid file request');
}
class Saef_modify
{
var $settings = array();
var $name = 'SAEF Modify';
var $version = '1.0';
var $description = 'SAEF - modify post data for the cracktastic forms';
var $settings_exist = 'n';
var $docs_url = '';
var $url_fields = array(11, 15, 61, 62, 63);
function mod_post()
{
global $FNS, $IN, $EXT, $OUT, $STAT;
if ($EXT->last_call !== FALSE)
{
$s = $EXT->last_call;
}
$this->variable_check();
}
function variable_check()
{
global $FNS, $IN, $EXT, $OUT;
foreach ($this->url_fields AS $val)
{
if (isset($_POST['field_id_'.$val]) AND $_POST['field_id_'.$val] != '' AND substr($_POST['field_id_'.$val], 0, 4) != "http" AND ! ereg('://', $_POST['field_id_'.$val]))
{
$_POST['field_id_'.$val] = "http://".$_POST['field_id_'.$val];
}
}
}
function activate_extension()
{
global $DB;
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => "Saef_modify",
'method' => "mod_post",
'hook' => "weblog_standalone_insert_entry",
'settings' => "",
'priority' => 1,
'version' => $this->version,
'enabled' => "y"
)
)
);
}
function disable_extension()
{
global $DB;
$DB->query("DELETE FROM exp_extensions WHERE class = 'Saef_modify'");
}
}
?>
I’d use the submit_new_entry_start, instead of the saef hook I was using. And the above is simplified- sorta. No reason for variable_check() to exist- just pull it all into the mod_post function and return. I did a lot of ripping out to simplify things.
That help?