Posts

Showing posts with the label Admin

Admin Url Redirecting To Localhost/admin

Answer : First change from http://localhost/sitename to http://127.0.0.1/sitename/ second, after doing this remove var/cache folder. Check your  Baseurl  and  Baseurl secure    Change From :- localhost To :- 127.0.0.1 Then Run This Command :- sudo php bin/magento cache:flush sudo php bin/magento cache:clean

Wordpress - Add A Separator To The Admin Menu?

Answer : Here's a quick and dirty way to get what you want. Background WordPress stores admin menu sections in a global array called $menu . To add a separator you add an element to the $menu array using an index that is between the indexes of the options that you want to separate. Using the add_admin_menu_separator() function So I've written a function to encapsulate the logic for this I called add_admin_menu_separator() . You'll need to pick an array index number that is higher than the option after which you want to add a separator, and then call the function add_admin_menu_separator() passing said index as your parameter. For example: add_admin_menu_separator(37); The add_admin_menu_separator() function itself Here's the definition of the function add_admin_menu_separator() which you can copy into your theme's functions.php file. Yes it is arcane but then so is the code that creates and uses the global $menu array. (Plans are to eventu...

Create An Admin User Programmatically In WordPress

Answer : This will create an admin user if placed in a themes functions.php file. Please change the first three variables as needed. /* * Create an admin user silently */ add_action('init', 'xyz1234_my_custom_add_user'); function xyz1234_my_custom_add_user() { $username = 'username123'; $password = 'pasword123'; $email = 'drew@example.com'; if (username_exists($username) == null && email_exists($email) == false) { // Create the new user $user_id = wp_create_user($username, $password, $email); // Get current user object $user = get_user_by('id', $user_id); // Remove role $user->remove_role('subscriber'); // Add role $user->add_role('administrator'); } } Accepted answer has issues and will throw a fatal error when its run twice, because the $user_id will be empty the second time. A work around for the issue: function rndprfx...