One time username change from frontend?

Just add a meta record that tracks the state of the username-changing actions: $user = wp_get_current_user(); $did_one_change = get_user_meta($user->ID, ‘changed_username’, true); if($did_one_change !== false) wp_die(‘You already changed your user name once!’); wp_update_user(array( ‘ID’ => $user->ID, ‘first_name’ => $_POST[‘first_name’], ‘last_name’ => $_POST[‘last_name’], )); // here add a meta entry that suggests the user has changed their … Read more

Why won’t register_setting() create a setting?

I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my_plugin_settings has not been created. I know sometimes I forget to add the actual admin part in which generally looks something like this: settings_fields( ‘my_plugin_settings’ ); do_settings_sections( ‘my_plugin_settings’ ); submit_button(); Or is … Read more

working Custom Post Type and Widget code no longer works when moved from functions.php to plugin

If all you want is for your plugin to work, simply replace register_activation_hook( __FILE__, ‘activate_my_careers’ ); with add_action( ‘plugins_loaded’, ‘activate_my_careers’ ); If you want to understand why your new plugin isn’t working, then you need to understand WordPress hooks. I would encourage you to carefully read the WordPress Plugin API. The first hook available to … Read more

PHPUnit test plugin activation

Actually you cannot activate your plugin using WP_UnitTestCase, because in the bootstrap.php you’ve already loaded your plugin as a mu-plugin. What I can suggest you to test your plugin activation is: call the do_action(‘activate_’ . FULL_ABSPATH_TO_YOUR_PLUGIN_PHP), where FULL_ABSPATH_TO_YOUR_PLUGIN_PHP will be something like: var/www/html/wordpress/wp-content/plugins/hello-world/hello-world.php In this example the hello-world plugin revoke’s a specified user’s capabilities on … Read more

WordPress metabox file upload in custom post [duplicate]

For WordPress metabox file upload in custom post. please refer Below link http://code.tutsplus.com/articles/attaching-files-to-your-posts-using-wordpress-custom-meta-boxes-part-1–wp-22291 or you can use following plugins https://wordpress.org/plugins/simple-fields/ http://www.advancedcustomfields.com/ both plugin best for custom field . you can also create reapeatable fields