krumch,
Thanks for the help. In reading the code, I figured it out. Here is how I did it:
Added a function to my child-theme to auto-login with an automated export user:
require_once( ABSPATH . 'wp-includes/pluggable.php' );
function autologin() {
// PARAMETER TO CHECK FOR
if(isset($_GET['autologin'])) {
$user_login = $_GET['variable1'];
$user = get_user_by('login',$user_login);
$user_id = $user->ID;
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
$creds = array();
$creds['user_login'] = $user->user_login;
$creds['user_password'] = $_GET['variable2'];
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ){
echo $user->get_error_message();
}else{
wp_redirect('https://www.myurl.com/export');
}
exit;
}
}
// ADD CODE JUST BEFORE HEADERS AND COOKIES ARE SENT
add_action( 'after_setup_theme', 'autologin' );
So by accessing the right url with the username and password as variables (I’m just making this a link on the right person’s desktop), I can autologin and go to the page to start the export.
On the page itself, I put the php to POST to a the export function (this can be re-factored, but as I said, I’m not too great with php or wordpress):
<body onLoad="ws_plugin__s2member_pro_export_users_form.submit(); loggeroutter();">
[insert_php]
echo '<form method="post" name="ws_plugin__s2member_pro_export_users_form" id="ws-plugin--s2member-pro-export-users-form">';
echo '<input type="hidden" name="ws_plugin__s2member_pro_export_users" id="ws-plugin--s2member-pro-export-users" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-pro-export-users")).'" />';
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_start" id="ws-plugin--s2member-pro-export-users-start" style="width:100px;display:none;" value="1" />';
echo '<input type="text" autocomplete="off" name="ws_plugin__s2member_pro_export_users_limit" id="ws-plugin--s2member-pro-export-users-limit" style="width:100px; display:none;" value="1000" />';
echo '<input type="submit" value="Export Now" style="font-size:120%; font-weight:normal;display:none;" />';
echo '</form>';
[/insert_php]
I use a plugin to place javascript on that page to submit the form automatically and after a few seconds logout of wordpress:
<script type="text/javascript">
function submit(form)
{
document.form.submit();
}
function loggeroutter()
{
var LogoutURL = "<?php echo wp_logout_url(); ?>";
setTimeout(function () {
window.location.assign(LogoutURL.replace(/&/g, "&"));
}, 2000);
}
</script>
Viola! A bookmark on the desktop logs into WP, goes to my export page, downloads the S2Member export, and then logs back out. Yes!
Thanks to everyone for helping.