Echoing a variable inside a function

Use the Settings API. A look at my latest plugin may help you to understand how to register a save function for your fields. Most relevant excerpt: /** * Register custom settings for the fields. * * @see save_settings() * @see print_input_field() * @return void */ public function add_contact_fields() { register_setting( ‘general’, $this->option_name, array ( … Read more

How can I show the contents of only a few users

To show content only for users with role ‘agent’, try to use this snippet: <?php if ( ( $user = wp_get_current_user() ) && in_array( ‘agent’, $user->roles ) ) { ?> ///here the content <?php } ?> If you want to block users by ID, check the following snippet: <?php if ( ( $user = wp_get_current_user() … Read more

How to create a drop down list with pages to a themes options page?

I have found the solution. I used the wordpress function wp_dropdown_pages <?php function combo_select_page_callback() { $options = get_option(‘function plugin’); wp_dropdown_pages( array( ‘name’ => ‘function plugin[ID used to identify the field throughout the theme]’, ‘echo’ => 1, ‘show_option_none’ => __( ‘&mdash; Select &mdash;’ ), ‘option_none_value’ => ‘0’, ‘selected’ => $options[‘ID used to identify the field throughout … Read more

Editing options pages?

I just did some searching and found this in the codex: add_settings_field( ‘myprefix_setting-id’, ‘This is the setting title’, ‘myprefix_setting_callback_function’, ‘general’, ‘myprefix_settings-section-name’, array( ‘label_for’ => ‘myprefix_setting-id’ ) ); Here is the link to the codex http://codex.wordpress.org/Function_Reference/add_settings_field Looks as simple as choosing the right slug like ‘general’ to add an option to the general settings page. I … Read more

update_options and unique filenames

Welcome to the lions den So you’re willing to get down into the blazing furnace or the lions den and change the upload path. This is so not a good idea without investigating what is happening behind the scenes. I can’t give you a full write up, as there’s so much involved, like filters, options … Read more

Implementing action correctly

do_action() does not use a returned value. It works more like the onload event in JavaScript: You cannot undo the load. To change a value you need filters. If you want to change the option content, hook into pre_update_option_{$option_name} very late (with a high priority parameter): add_filter( ‘pre_update_option_myp_settings’, ‘myp_settings_et_validate’, 100, 3 ); function myp_settings_et_validate( $option, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)