This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
So, you’ve stumbled upon the granted_super_admin action hook and are curious about its magic? Well, you’ve come to the right place! Let’s dive right in and see how this hook can be a game-changer for your WordPress site.
granted_super_admin action
This action fires after a user is granted Super Admin privileges. It’s crucial to register this hook using add_action
. You can either place it in your theme’s functions.php
file or, better yet, in a custom WordPress plugin to ensure nothing breaks when you update your theme.
At WePlugins, we always recommend creating a custom WordPress plugin for using hooks, as it keeps the functionality intact across theme updates.
The function execute_on_granted_super_admin_event
is defined to take one parameter. It’s registered with add_action
, where the first parameter is the hook name, the second is the function to call, the third is the priority, and the last is the number of arguments to pass.
If you ever need to remove a registered hook, remove_action
is your friend!
Parameters
Below is the required parameter for using this hook.
- $user_id: (int) ID of the user that was granted Super Admin privileges.
Example 1: Basic Implementation
Here’s a straightforward example of using the granted_super_admin
hook.
function weplugins_execute_on_granted_super_admin_event($user_id){ // Add your custom functionality here. } add_action( "granted_super_admin", "weplugins_execute_on_granted_super_admin_event" , 10, 1);
Example 2: Removing the Hook
To remove a hook callback, use the example below. Be sure to provide the same callback function name, priority, and number of arguments.
remove_action( "granted_super_admin", "weplugins_execute_on_granted_super_admin_event", 10, 1 );
Example 3: Advanced Usage
For those who like to get a bit more advanced, here’s how you might use this action hook in a more complex scenario, such as logging the event or sending a notification.
function weplugins_advanced_granted_super_admin_event($user_id){ // Log or notify about the Super Admin privilege grant. } add_action( "granted_super_admin", "weplugins_advanced_granted_super_admin_event" , 20, 1);
Need more help or customization? Feel free to Contact Us. Our team at WePlugins is always ready to assist you with your WordPress needs!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.