Hi snyzio,
The Individual Redirects are just meta data for the post.
So, to create a redirect programatically, you can do something like below.
Put this in your functons.php file (or some file that will be called when the post is created):
function create_redirect_for_webinar( $atts = array() ){
if( !is_array( $atts ) )
return;
$defaults = array(
'post_id' => '0',
'active' => 1,
'url' => '',
'type' => '301',
'newwindow' => 0,
'nofollow' => 0,
'rewrite' => 0
);
extract( shortcode_atts($defaults, $atts) );
if( $post_id == '0' || $url == '' )
return;
// some validation
$type = !in_array( $type, array( '301', '302', '307', 'meta' ) ) ? '301' : $type;
$active = (int) $active == 1 ? 1 : 0;
$newwindow = (int) $newwindow == 1 ? 1 : 0;
$nofollow = (int) $nofollow == 1 ? 1 : 0;
$rewrite = (int) $rewrite == 1 ? 1 : 0;
// set required meta
add_post_meta( $post_id, '_pprredirect_url', $url );
add_post_meta( $post_id, '_pprredirect_type', $type );
add_post_meta( $post_id, '_pprredirect_active', $active );
//set optional meta
if( $rewrite == 1 )
add_post_meta( $post_id, '_pprredirect_rewritelink', 1 );
if( $newwindow == 1 )
add_post_meta( $post_id, '_pprredirect_newwindow', '_blank' );
if( $nofollow == 1 )
add_post_meta( $post_id, '_pprredirect_relnofollow', 1 );
}
Then to use it, you would put this where your posts are created:
Be sure to make sure the $post->ID is replaced with your variable for the post id if not using $post global AND you add the correct URL of the Redirect.
$atts = array(
'post_id' => $post->ID, // your post ID of the created post
'url' => 'add redurect URL here', // redirect URL
//you can add the other attributes here is you need them
);
// call our function
create_redirect_for_webinar( $atts );
We will be adding something like this to the plugin soon, but with this function you will be safe when we do.
Let me know if you have questions or issues.
Warm regards,
Don