| @@ -170,16 +170,23 @@ | ||
| 170 | 170 | |
| 171 | 171 | // Check the user role |
| 172 | 172 | $roles = automatorwp_get_editable_roles(); |
| 173 | 173 | |
| 174 | - if( ! isset( $roles[$user_data['role']] ) ) { | |
| 174 | + if( ! isset( $roles[$user_data['role']] ) ) | |
| 175 | 175 | $user_data['role'] = 'subscriber'; |
| 176 | + | |
| 177 | + // Check if role comes from role_custom (which could come from a tag) | |
| 178 | + if( $action_options['role_custom'] === 'administrator' ) { | |
| 179 | + // Security filter to allows through code create administrator users if not desired | |
| 180 | + $allow_admin = apply_filters( 'automatorwp_allow_create_admin_user_from_custom_role', false, $action, $user_id, $action_options, $automation ); | |
| 181 | + | |
| 182 | + if( ! $allow_admin ) | |
| 183 | + $user_data['role'] = 'subscriber'; | |
| 176 | 184 | } |
| 177 | 185 | |
| 178 | 186 | // Generate the user password |
| 179 | - if( empty( $user_data['user_pass'] ) ) { | |
| 187 | + if( empty( $user_data['user_pass'] ) ) | |
| 180 | 188 | $user_data['user_pass'] = wp_generate_password( 24 ); |
| 181 | - } | |
| 182 | 189 | |
| 183 | 190 | // Insert the user |
| 184 | 191 | $this->user_id = wp_insert_user( $user_data ); |
| 185 | 192 | |