botguy
Forum Replies Created
-
No, there is a WP Super Cache plugin installed but it is not activated.
Forum: Plugins
In reply to: [amr users] Export CSV without ID column?Resolved!
Forum: Plugins
In reply to: [amr users] Export CSV without ID column?Awesome! Thank you!
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.
So, it looks like I need to access the export() function in exports.inc.php in the s2member pro classes. Anyone know how I can do that? It is a static public function.
Alright, I got the code working, in case anyone is interested. I take the ID of the user and add 150 to it in this version (ours internally is a different system). It also includes auto-logging in anyone who registers:
add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration'); function s2_auto_login_after_registration($vars = array()) { if (!is_admin() && $vars['processed'] === 'yes') { wp_new_user_notification($vars['user_id'], $vars['pass']); wp_set_auth_cookie($vars['user_id'], false, is_ssl()); //begin assigning id codes $numbertoadd = "150"; $idnumber = $vars['user_id']; $idcode = $numbertoadd + $idnumber; settype($idcode, "string"); $custom_fields = get_user_option('s2member_custom_fields', $vars['user_id']); $custom_fields['id_code'] = $idcode; update_user_option($vars['user_id'], 's2member_custom_fields', $custom_fields); //end assigning team codes wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first'); exit(); } }
Should I use the
add_action(‘init’, ‘c_ws_plugin__s2member_pro_exports::export’, 3);
action to automate an export?So does anyone know how to call the export function? I’ve been looking without much success…
Ok. So I think I understand.
Yes, I can get the information I desire by using the export in the “Import/Export” menu panel.
However, I do not know how to automate whatever function happens when I click “export”. If I know what to call and how to access that function, then I can do the rest of the automation myself.
Thanks.
How so? I am trying to automate it and I do not see that ability.
I’m Sorry, I wasn’t clear:
I can create a CSV from an array of information, but I have not had success on creating an array from S2Member’s custom fields (which are kept in meta fields I think?). In order words, I know and CAN make a CSV, but I don’t know how to get any of the information from S2Member to put into the CSV.
Does that make sense?
Yes, I did, and the link shows up for everyone. It just says “You do not have permission to create events” on the “My Events” page. I’d prefer for that link not to show up at all.