dune1982
Forum Replies Created
-
Yes here it is. It is already adapted for pieregister. But if you use a diffrent add_action you can start the function otherwise
// Function to add expiry on registration to a user role $current_user->ID function new_registerd_member( $user ) { //$current_user = wp_get_current_user(); //$user = new WP_User( $current_user->ID ); // Remove role //$user->remove_role( 'subscriber' ); // Add role //$user->add_role( 'mycustomrole' ); // This adds the expire user stuff to the role posible date_in_block 'years' 'months' 'weeks' 'days' global $expire_users; $expire_settings = $expire_users->admin->settings->get_default_expire_settings(); $expire_data = array( 'expire_user_date_type' => $expire_settings['expire_user_date_type'], 'expire_user_date_in_num' => 1, 'expire_user_date_in_block' => 'months', 'expire_user_date_on_timestamp' => $expire_settings['expire_timestamp'], 'expire_user_role' => $expire_settings['expire_user_role'], 'expire_user_reset_password' => $expire_settings['expire_user_reset_password'], 'expire_user_email' => $expire_settings['expire_user_email'], 'expire_user_email_admin' => $expire_settings['expire_user_email_admin'], 'expire_user_remove_expiry' => $expire_settings['expire_user_remove_expiry'] ); $user = new Expire_User( $user->ID ); $user->set_expire_data( $expire_data ); $user->save_user(); } add_action( 'pie_register_after_register_validate', 'new_registerd_member', 10,1 );
Hope this helps
Hello,
yes that really helped. It is working now. Thank you so much, I will remember the help once my website is earning some money.Forum: Plugins
In reply to: [WooCommerce] WooCommerce Change User Role on Purchase of Specific ProductHello,
is there a way to achive the same thing but not for a specific product but for more products like from a certain category or better with a specific keyword?Forum: Plugins
In reply to: [Expire Users] Auto sex expiry date after WooCommerce purchaseHello njinok
this code is working in my functions.php it will set the date on purchase of the product with the ID 1958The first part will also change the user role to newrole, I don’t know if you need that.
function lgbk_add_member( $order_id ) { $order = new WC_Order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; $product_variation_id = $item['variation_id']; if ( $order->user_id > 0 && $product_id == '1958' ) { update_user_meta( $order->user_id, 'paying_customer', 1 ); $user = new WP_User( $order->user_id ); // Remove role $user->remove_role( 'subscriber' ); // Add role $user->add_role( 'newrole' ); // This adds the expire user stuff to the role posible date_in_block 'years' 'months' 'weeks' 'days' global $expire_users; $expire_settings = $expire_users->admin->settings->get_default_expire_settings(); $expire_data = array( 'expire_user_date_type' => $expire_settings['expire_user_date_type'], 'expire_user_date_in_num' => 12, 'expire_user_date_in_block' => 'months', 'expire_user_date_on_timestamp' => $expire_settings['expire_timestamp'], 'expire_user_role' => $expire_settings['expire_user_role'], 'expire_user_reset_password' => $expire_settings['expire_user_reset_password'], 'expire_user_email' => $expire_settings['expire_user_email'], 'expire_user_email_admin' => $expire_settings['expire_user_email_admin'], 'expire_user_remove_expiry' => $expire_settings['expire_user_remove_expiry'] ); $user = new Expire_User( $order->user_id ); $user->set_expire_data( $expire_data ); $user->save_user(); } } } add_action( 'woocommerce_order_status_completed', 'lgbk_add_member' );
It seems to work but $current_user->ID doesn’t have the right user id in it. So the problem is to geht the user ID of that new registerd user. If I use $user_id the admin (UserID is 1) gets an expiry date.
Hello
Thank you for your reply, I tried the following code in my functions.php// Function to add expiry on registration to a user role function new_registerd_member( ) { $current_user = wp_get_current_user(); $user = new WP_User( $current_user->ID ); // This adds the expire user stuff to the role posible date_in_block 'years' 'months' 'weeks' 'days' global $expire_users; $expire_settings = $expire_users->admin->settings->get_default_expire_settings(); $expire_data = array( 'expire_user_date_type' => $expire_settings['expire_user_date_type'], 'expire_user_date_in_num' => 1, 'expire_user_date_in_block' => 'months', 'expire_user_date_on_timestamp' => $expire_settings['expire_timestamp'], 'expire_user_role' => $expire_settings['expire_user_role'], 'expire_user_reset_password' => $expire_settings['expire_user_reset_password'], 'expire_user_email' => $expire_settings['expire_user_email'], 'expire_user_email_admin' => $expire_settings['expire_user_email_admin'], 'expire_user_remove_expiry' => $expire_settings['expire_user_remove_expiry'] ); $user = new Expire_User( $current_user->ID ); $user->set_expire_data( $expire_data ); $user->save_user(); } add_action( 'pie_register_after_register_validate', 'new_registerd_member' );
Sadly nothing happened on new registration, wordpress acted as usual.
Ok I got it now, some custom code in the functions.php
Please keep on developing this plugin, I would love to have different expire options, like different times for registration and my case on purchase of a product.
Forum: Plugins
In reply to: assign user to a role for a certain time periodeOk I got it to work now,
the Plugin expire user and some custom code in the functions.php did the trick// Function to change userrole on purchase of specific product plus adding a expiration date. function custom_add_member( $order_id ) { $order = new WC_Order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; $product_variation_id = $item['variation_id']; if ( $order->user_id > 0 && $product_id == '1958' ) { update_user_meta( $order->user_id, 'paying_customer', 1 ); $user = new WP_User( $order->user_id ); // Remove role $user->remove_role( 'subscriber' ); // Add role $user->add_role( 'supportmember' ); // This adds the expire user stuff to the role global $expire_users; $expire_settings = $expire_users->admin->settings->get_default_expire_settings(); $expire_data = array( 'expire_user_date_type' => $expire_settings['expire_user_date_type'], 'expire_user_date_in_num' => $expire_settings['expire_user_date_in_num'], 'expire_user_date_in_block' => $expire_settings['expire_user_date_in_block'], 'expire_user_date_on_timestamp' => $expire_settings['expire_timestamp'], 'expire_user_role' => $expire_settings['expire_user_role'], 'expire_user_reset_password' => $expire_settings['expire_user_reset_password'], 'expire_user_email' => $expire_settings['expire_user_email'], 'expire_user_email_admin' => $expire_settings['expire_user_email_admin'], 'expire_user_remove_expiry' => $expire_settings['expire_user_remove_expiry'] ); $user = new Expire_User( $order->user_id ); $user->set_expire_data( $expire_data ); $user->save_user(); } } } add_action( 'woocommerce_order_status_completed', 'custom_add_member' );
Oh by the way, I have made a German translation if you whant to include it.
Forum: Fixing WordPress
In reply to: custom loop that shows post from till dateThank you,
I read that and I had a look at The Loop in Action post. But I can’t even get a basic thing to work.
I tried this code
<?php
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
get_sidebar();
get_footer();
?>
But I have no Idea where to place that code, I tried it in a test.php file and placed it inside of the wp folder, but that didn’t work.I guess I need to now more about php programming
Forum: Plugins
In reply to: newsletter pluginOr is there a way to automaticaly copy the inputs from the registration form into the newsletter form if they are on the same page and have them both submited by one click?
Forum: Hacks
In reply to: function and if check in phpThank you so much guys for your input.
@diondesigns your code works perfect thanks for the hint.@wspencer your code did not work, it seems like it is changing nothing as the result is DE or CH or A
Forum: Plugins
In reply to: woocommerce – list produkt categorys in widgetSolved
Forum: Plugins
In reply to: woocommerce – list produkt categorys in widgetOk this code solves the problem,
ul.children { padding-left: 15px; }
Forum: Hacks
In reply to: How do I add a filter for a function in the functions.phpThank you,
it seems like the custom css is working too. Boy my custom css file is getting long ??