Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




set_user_setting [ WordPress Function ]

set_user_setting ( $name, $value )
Parameters:
  • (string) $name The name of the setting.
  • (string) $value The value for the setting.
Returns:
  • (bool) true if set successfully/false if not.
Defined at:



Add or update user interface setting.

Both $name and $value can contain only ASCII letters, numbers and underscores. This function has to be used before any output has started as it calls setcookie().

Source


<?php
function set_user_setting$name$value ) {

    if ( 
headers_sent() )
        return 
false;

    
$all get_all_user_settings();
    
$name preg_replace'/[^A-Za-z0-9_]+/'''$name );

    if ( empty(
$name) )
        return 
false;

    
$all[$name] = $value;

    return 
wp_set_all_user_settings($all);
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics