pgrafix
Forum Replies Created
-
Forum: Plugins
In reply to: [First Order Discount Woocommerce] Wordfence vulnerability report in 1.21Thank you!
Forum: Plugins
In reply to: [First Order Discount Woocommerce] Wordfence vulnerability report in 1.21Any movement on getting this vulnerability fixed?
I guess what I am getting at, is what are you using UM for?
Do you really need UM or will WPJM accomplish everything you need?
Is it possible to have the other plugin use roles set my UM? If so, then you should be able to create the roles via UM and then select them under the other plugin. User roles are generally available site wide from my understanding.
Have you removed my code? If so, I would do that first before retesting.
What are you settings for user registration under Settings>General?
Looking at your registration page, you don’t need the code above since you already give the option to register as either a Candidate or an Employer.
The code I posted has two primary purposes:
1. It prevents anyone from registering unless they have a registration code (the um_custom_validate_username function).
2. Prevents a registrant from choosing a role at registration and instead removes the default role (set in the WP settings) and then has their role reassigned based upon the registration code they used. (my_after_save_registration_details function).I needed this for a very particular setup that involved two unconnected sites.
Are you no longer wanting to give registrants the choice of Candidate or Employer?
gflower1:
CODE1 and CODE2 are whatever registration codes you want to use for the role assignment conditions. Obviously, they need to be different to allow for the appropriate user role to be assigned at registration.
As for the Invalid Nonce error I can only think of 2 things ATM that are going wrong for you:
1. Make sure you aren’t logged in as any user when you try to register as a new user.
2. Make sure the user role referenced in the script is for a user role that already exists – this script only removes the default Subscriber role from a new registration, then assigns a different role (it doesn’t create it) based on the code used.Got it working. For anyone who is interested in having a registration code enabled form that assigns a user role based upon the code:
function um_custom_validate_username( $key, $array, $args ) { global $regcode; $regcode = $args[$key]; if ( isset( $regcode ) && $regcode !== 'CODE1' && $regcode !== 'CODE2' ) { UM()->form()->add_error( $key, __( 'Please enter valid registration code.', 'ultimate-member' ) ); } } add_action( 'um_custom_field_validation_registration_code', 'um_custom_validate_username', 30, 3 ); function my_after_save_registration_details( $user_id, $submitted ) { global $regcode; $user = new WP_User( $user_id ); if ( $regcode == 'CODE1' ) { $user->remove_role( 'subscriber' ); $user->add_role( 'role1' ); } elseif ($regcode == 'CODE2') { $user->remove_role( 'subscriber' ); $user->add_role( 'role2' ); } } add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
The first function sets and verifies the codes. You would replace ‘CODE1’ or ‘CODE2’ with the codes you want to use. Theoretically, could have MANY codes, but would be best to handle more than a few in an array.
The second function checks the entered code, removes the generic Subscriber role and updates to the desired role. Of course, replace ‘role1’ and ‘role2’ with the appropriate EXISTING roles.
Why use this instead of separate registration forms or the role drop down field available in UM? First, it is not possible to hide a form for one type of registrant from the other type of registrant. Systems like UM, Adminimize, etc. rely on the user being logged in to tailor visibility to a specific role. Second, in my situation, I can’t really have the registrant selecting their role – that needed to be determined on criteria that the registrant is unaware of.
Reread the docs a little closer on the “um_registration_user_role” hook. I still believe it should have been a viable option since it would change the role on the form depending on the code, but I couldn’t get it to work.
- This reply was modified 4 years, 9 months ago by pgrafix.
After some sleep I realized that the second function couldn’t work because it has no idea what registration code was used since $key was not within its scope. So, revised first function to:
function um_custom_validate_username( $key, $array, $args ) { global $regcode; $regcode = $args[$key]; if ( isset( $regcode ) && $regcode !== 'CODE1' && $regcode !== 'CODE2' ) { UM()->form()->add_error( $key, __( 'Please enter valid registration code.', 'ultimate-member' ) ); } } add_action( 'um_custom_field_validation_registration_code', 'um_custom_validate_username', 30, 3 );
This works fine and tells me that the global $regcode should be available for further assessment. It’s the second check and assign function that still doesn’t function. After re-reading the documentation I realize that set_role cannot be used until the user actually exists, thus, it will not work here.
Any help would be greatly appreciated.
Forum: Plugins
In reply to: [Yotpo Reviews for WooCommerce (Unofficial)] Star Ratings on Shop PageYes, I was able to solve the problem by excluding the star class from lazy loading.
As for the second “issue”, is that a setting in the actual Yotpo account? I do not see that in the plugin settings.
Forum: Plugins
In reply to: [Yotpo Reviews for WooCommerce (Unofficial)] Dual Reviews TabsThat fixed it. Although I have another issue, but I will start a new thread for it.
Thanks!
Forum: Plugins
In reply to: [PHP Everywhere] WP 5.3 CompatibilityExcellent. Thank you for your prompt response.
Forum: Fixing WordPress
In reply to: Horizontal Scrolling on SiteI am also having the same issue with a site in Safari only, Cassiie.
We are using Astra + Elementor. Which theme are you using?
Forum: Themes and Templates
In reply to: [Astra] After the last update, I now get js errorTo clarify my statement, I am only seeing the error when a caching plugin is on. In my case I am not using Autoptimize, rather I am using CloudWay’s Breeze plugin.
When the error is present, I am getting some odd positioning of menus and Elementor slider text.