How to set different users for different pages?

Create a subfolder in plugins folder, name it ‘MyRestict’. In This folder put the following php: <?php /** * Plugin Name: My Restict * Plugin URI: http://wordpress.stackexchange.com/questions/112566/how-to-set-different-users-for-different-pages * Author: G.M. */ function my_restict_template_filter( $template ) { if ( is_page() ) { $post = get_queried_object(); $allowed = (string) get_post_meta($post->ID, ‘allowed_users’, true); if ( $allowed ) $allowed … Read more

Link to Authors blog posts

the_author_ID() says in Codex: It displays the unique numeric user ID for the author of a post; the ID is assigned by WordPress when a user account is created. This tag must be used within The Loop. So, it won’t work. Try using the following code* within a loop: <li class=”author vcard”> <a class=”url fn … Read more

Designing a member area on my site

If you never heard of WordPress, you can have an overview at the Codex in Getting Started with WordPress and explore the topics as the need arrives. G.M’s linked Answer has very nice information for your use-case, and sample code with advanced techniques. Worth bookmarking. To get really started, learn how to make a Child … Read more

Add a column before username in the users profile table

Ok, I solved it by unsetting $defaults and reconstructing it after adding the company function add_company_column($defaults) { unset($defaults); $defaults[‘company’] = __(‘Company’); $defaults[‘username’] = __(‘username’); $defaults[‘name’] = __(‘Name’); $defaults[’email’] = __(‘Email’); return $defaults; }

import (migration) user database to wp-users

get all data from DB1( non-wp-database ) and save to an $array. Use this wordpress code inside your functions.php for insert users into DB2 ( wordpress database). function cxg_wp_insert_user() { foreach ( $array as $arr ) { $user_data = array( ‘ID’ => ”, ‘user_pass’ => wp_generate_password(), ‘user_login’ => $loginName, ‘user_nicename’ => $nicename, ‘user_url’ => ”, … Read more

Validate user meta and redirect

Here is how I would do it: function save_extra_user_profile_fields( $user_id ) { if (!isset($_POST[‘address’]) || empty($_POST[‘address’])) { // this field was not set or was empty // do your action wp_redirect( home_url() ); // or profile page exit; } else { // field was set and contains a value // do your action update_user_meta( $user_id, … Read more

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