Function: swp_get_user_options()

  1. Home
  2. Knowledge Base
  3. Developers
  4. Function: swp_get_user_options()

Not the solution you were looking for?

Click the link below to submit a support ticket. If you are a Social Warfare - Pro license holder, you can log into your Account page to submit a ticket.
Submit Ticket

Description

This function allows you to fetch all of the options that the user has set in on the options pages. It will be returned as an array of keys and values.

Example Usage

// Fetch the user assigned options
$swp_user_options = swp_get_user_options();

if($swp_user_options['some_checkbox_option'] == true):
    
    // Do something cool since the checkbox was checked

endif;

Parameters

This function accepts no parameters.

Return

The function returns an array of options in a format much like this example. However, to see the real values, you’ll want to run a var_dump() prior to utilizing the data.

array(5) {
    ["checkbox_option"]=>
    bool(true)
    ["textbox_option"]=>
    string(17) "User's Text Input"
    ["select_option"]=>
    string(11) "choicethree"
    ["color_option"]=>
    string(7) "#ffffff"
    ["sortable_option"]=>
    array(4) {
        ["trueLove"]=>
        string(9) "True Love"
        ["rhymingIMeanIt"]=>
        string(17) "Rhyming I mean it"
        ["toBlave"]=>
        string(8) "To Blave"
        ["revenge"]=>
        string(7) "Revenge"
     }
}

Was this article helpful?

Related Articles