Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+13 votes
557 views
in Plugins by
edited by

Building my first plugin and I would like to ask a quick question. All options of the  plugin are save to the qa_options table? For example I wrote this array:


array(
'label' => 'Show real name of users instead of username',
'note'=> 'If on, plugin will display the real name of users if they saved it in profile settings. Otherwise it will display the username',
'tags' => 'NAME="pf_show_realname"',
'value' => qa_opt('pf_show_realname'),
'type' => 'checkbox',
),

 This means that the plugin will create a field pf_show_realname which will store the values 0 or 1 depending on the option checkbox. Am i right? Is this how it works ?

PS:  This script rocks :)

Q2A version: 1.8.6

1 Answer

+4 votes
by
selected by
 
Best answer

No. That is just how you display a field in a form. The qa_opt() function is a getter (with one parameter) or a setter (with two parameters). In this case, it is just fetching the current value of the given title: pf_show_realname.

You're just missing the saving of the value. In order to do so you need to add a save button to the form and make sure you process the HTTP POST request by checking the save button has been pressed. There is a qa_clicked() function that makes this slightly easier.

It might be easier for you to check some other "Admin modules" (or modules that implement the admin_form() function), such as this one.

by
+3
Ok pupi got it. I have now my first functional plugin. ,,  I really wonder why Q2A isn't so popular!! I mean that it deserves more attention. I work as front end developer in a big company but I love  also the back end development. I will try to contribute as much as I can into this project.
by
+2
Q2A has a fantastic core. Hopefully we'll see it's full power soon ;)
by
+2
Agree it's core is awesome. I already built a plugin (though it's nothing special) and started to work on existing onsite notifications plugin. It's a little bit aged and i thing it needs a refresh.
...