• Hi there!

    I’m trying to get this code to work:

    add_action( 'wpmem_post_register_data', function( $fields ) {
         if ( wpmem_is_reg_type( 'wpmem' ) ) {
              wpmem_update_user_role( $fields['ID'], 'author' );
         }
    });
    

    What it should do is: set the user role of the registering user to ‘author’ IF the registration form is a wp-members registration form.

    The script works except the if-statement. I also tried to replace ‘wpmem’ with ‘woo_checkout’ to see if that works, but it didn’t either.

    Does someone know how to get this script to work?

    Many thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    This is an issue with the API function wpmem_is_reg_type().

    The function is intended to check a variable value in one of the plugin’s objects that indicates the specific registration process being run (such as WP-Members, WooCommerce, native WP, etc).

    It is not actually checking the correct object class for the value. The value is in the plugin’s user object class ($wpmem->user->reg_type), but it is being checked in the plugin’s main object class ($wpmem->reg_type).

    This will be fixed in the plugin’s next release, 3.4.2. In the meantime, it can be patched manually as described below.

    In the file includes/api/api.php, at line 476 in the wpmem_is_reg_type() function, look for the following line:

    return $wpmem->reg_type[ 'is_' . $type ];

    That should be changed to the following:

    return $wpmem->user->reg_type[ 'is_' . $type ];

Viewing 1 replies (of 1 total)
  • The topic ‘Change user role for WP-Members form’ is closed to new replies.