Function: swp_get_single_option()

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

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


This function allows you to fetch a single option value that the user has set on the options pages. It will be returned as a single value, unless calling a ‘sortable’ option field, in which case it will return an array sorted in the order that the user has placed them.

Example Usage

if(swp_get_single_option('some_checkbox_option') == true):
    // Do something cool since the checkbox was checked



This function accepts one required value.

(string)(required) The key associated with the option of which you wish to receive the value.


The function returns a value for a single option 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.

// A checkbox value

// A textbox value
string(17) "User's Text Input"

// A select value
string(11) "choicethree"

// A color picker value
string(7) "#ffffff"

// A sortable value
array(4) {
    string(9) "True Love"
    string(17) "Rhyming I mean it"
    string(8) "To Blave"
    string(7) "Revenge"

Was this article helpful?

Related Articles