snipt

Ctrl+h for KB shortcuts

PHP

WordPress functions.php code: modify role name

1
2
3
4
5
6
7
8
function wps_change_role_name() {
    global $wp_roles;
    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();
    $wp_roles->roles['contributor']['name'] = 'Owner';
    $wp_roles->role_names['contributor'] = 'Owner';
}
add_action('init', 'wps_change_role_name');
https://snipt.net/embed/fdf0c9f28ea3b751eb31cf0d1dd0d311/
https://snipt.net/raw/fdf0c9f28ea3b751eb31cf0d1dd0d311/
fdf0c9f28ea3b751eb31cf0d1dd0d311
php
PHP
8
2016-09-27T02:33:11
True
False
False
Jan 17, 2016 at 05:19 PM
/api/public/snipt/143622/
wordpress-functionsphp-code-modify-role-name
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">function wps_change_role_name() {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> global $wp_roles;</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> if ( ! isset( $wp_roles ) )</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> $wp_roles = new WP_Roles();</span> </span><span id="L-5"><a name="L-5"></a><span class="x"> $wp_roles-&gt;roles[&#39;contributor&#39;][&#39;name&#39;] = &#39;Owner&#39;;</span> </span><span id="L-6"><a name="L-6"></a><span class="x"> $wp_roles-&gt;role_names[&#39;contributor&#39;] = &#39;Owner&#39;;</span> </span><span id="L-7"><a name="L-7"></a><span class="x">}</span> </span><span id="L-8"><a name="L-8"></a><span class="x">add_action(&#39;init&#39;, &#39;wps_change_role_name&#39;);</span> </span></pre></div> </td></tr></table>
functions.php, wordpress

PHP

Images - Add custom sizes

1
2
3
4
//Lingo: add custom thumbnail size for the project page header
if ( function_exists( 'add_image_size' ) ) { 
	add_image_size( 'name-of-size-goes-here', 500, 500, true ); //(cropped)
}
https://snipt.net/embed/c810aa3ca84d34cef85ca1df9179c705/
https://snipt.net/raw/c810aa3ca84d34cef85ca1df9179c705/
c810aa3ca84d34cef85ca1df9179c705
php
PHP
5
2016-09-25T17:50:59
True
False
True
Sep 06, 2013 at 08:15 AM
/api/public/snipt/79384/
images-add-custom-sizes
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">//Lingo: add custom thumbnail size for the project page header</span> </span><span id="L-2"><a name="L-2"></a><span class="x">if ( function_exists( &#39;add_image_size&#39; ) ) { </span> </span><span id="L-3"><a name="L-3"></a><span class="x"> add_image_size( &#39;name-of-size-goes-here&#39;, 500, 500, true ); //(cropped)</span> </span><span id="L-4"><a name="L-4"></a><span class="x">}</span> </span></pre></div> </td></tr></table>
Images, WordPress, functions.php
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.