Support » Plugin: Pie Register » pie register and expire user

  • Resolved dune1982

    (@dune1982)


    Hello,
    I use the latest Pie Register on my site and the plugin expire user. I want new registered users to be assigned to a role for a month. So I set the standart role for new users to that role and in expire users I have the option to have new registerd users expire to a role after a set time. However the two plugins seem to not work together as on a new registration the expire time is not set.

    I have a working function that will set the expire time for a role. I just don’t know where to place that function so it is called when a user registers, with pie register, or if it is easier on first login.

    https://wordpress.org/plugins/pie-register/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Genetech Solutions

    (@genetech)

    Hello,

    You can hook your function to the one of PR registration hooks.
    pie_register_after_register_validate
    pie_register_after_register

    Both hooks pass User object so you can retrieve it in your function.

    Hope it helps, please feel free to post if you have further questions.

    Thanks

    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.

    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.

    Plugin Author Genetech Solutions

    (@genetech)

    Hello,

    This hook gives you user object, so pass it in your function
    add_action( ‘pie_register_after_register_validate’, ‘new_registerd_member’, 10,1 );
    then in your function
    function new_registerd_member($user) {..}

    Hope it helps.

    Thanks

    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.

    Plugin Author Genetech Solutions

    (@genetech)

    Hello,

    We are glad you got it working and appreciate your willingness to help us. Well, you can still help by just writing us favorable words and rating at WordPress. Just pls click here.
    https://wordpress.org/support/view/plugin-reviews/pie-register

    Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘pie register and expire user’ is closed to new replies.