By default we have list of roles present in wordpress like administrator, editor, author etc. BY default we cannot add a new role to the current roles displayed in the wordpress system. We have so many pluggins which we need to check and find the suitable.
The below solution provides you a quick and better access to add a new role.
1. Open the wordpress folder
2. Select the themes folder and select your current theme.
3. If you have functions.php file open the file, If you dont have functions.php file copy the file from the other theme / base
theme and paste in your current theme.
4. At the last line of function.php file add the below lines.
"add_role('Role Name', 'Role Display Name', array( 'Capabilities'));"
Just by the above steps you would be able to add the New roles to your current system without any external plugins installation.
Monday, April 21, 2014
Create new role in wordpress
Monday, February 3, 2014
Remove spaces between two string
In PHP we have so many functions which are related to strings. The below examples explains how to remove the spaces between string.
1. str_replace
2. preg_replace.
str_replace:
This replaces the empty spaces. this can be used partially.
Example:
$string = str_replace(' ', '', $string);
preg_replace:
This will replace the nth spaces and removes the white spaces within all the string.
Example:
$string = preg_replace('/\s+/', '', $string);
Subscribe to:
Posts (Atom)