Hot answers tagged

4

It's a bit different in WP than in Drupal. First, the admin role is specifically designed to be the role that can do everything. Rather than try to restrict the admin role, it's best practice to create whatever custom roles you need - you would set up an almost-admin type role that has all the capabilities except the one you want to restrict. This is ...


3

You can do it without plugins, you just have to allow subscribers to see Private posts and pages, depending on what you want, so you have to put this code in your functions.php $subRole = get_role( 'subscriber' ); $subRole->add_cap( 'read_private_posts' ); $subRole->add_cap( 'read_private_pages' ); And then simply create a private post or page and it ...


3

I had the same problem, a custom role couldn't assign categories to my CPT. When doing register_taxonomy(), I added these capabilities: 'capabilities' => array ( 'manage_terms' => 'manage_options', //by default only admin 'edit_terms' => 'manage_options', 'delete_terms' => '...


3

I had to do something similar. What you need to do first is in each of your config files define the table prefix ... make sure that they are different. Example: WordPress installation 1: wp123_ WordPress installation 2: wp124_ Your first installation would be your main installation the one with the user table you want to use. Then in the second ...


3

You can't use Members to do exactly what you want. I use WP eBooks' "Network Roles" in tandem with Members to accomplish what you want: http://wpebooks.com/network-roles/


3

Membership plugin from Wpmudev.org should fit your needs: http://premium.wpmudev.org/project/membership/ This is step 2 of the registration process with Membership: EDIT: According to comments that membership should give access to certain custom post type i would suggest this: Create a template for that custom post type as single-premium-videos.php More ...


3

Paid Memberships Pro handles payment and user creation at the same time. The one difference vs. your specs is that PMPro doesn't wait for IPN verification and assumes the payment will go through and gives the user access immediately. http://wordpress.org/extend/plugins/paid-memberships-pro/ The reason we don't wait for verification is because depending on ...


3

Based on this statement... note: i want their profile called MY ACCOUNT to be on the nav bar ... and other parts of your description, I think what you want is not really to have pages that are "only members that are logged in". Despite the title of the questions, it sounds like you want a page that will show the current user's profile, which does only ...


2

Does a double install sound feasible and the right approach? Given your restrictions, yes...I can't think of any other way to do it with a single install. If there was a way to get the legacy software to control member accounts via any other system (perhaps dumping to a CSV which can then be read into a MySQL table via a script?) then you would be able to ...


2

Figured this out after finding this page: http://www.0to5blog.com/tips/protecting-wordpress-media-uploads-unless-user-is-logged-in/ That page contains the instructions I was looking for, exactly! I tweaked the dl-file.php code slightly to meet my needs: if ( !current_user_can( 'read_private_posts' ) || !is_user_logged_in() ) {


2

you can use something like this /** * Get City state from zipcode */ function rtp_get_city_state($location) { $details_url = 'http://maps.google.com/maps/api/geocode/json?address='.$location.'&sensor=false'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $details_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = ...


2

function bp_registrations_today($activated = false) { global $wpdb; $query = "SELECT COUNT(ID) FROM {$wpdb->prefix}users WHERE DATE(user_registered) = CURDATE()"; if ( $activated ) { $query .= " AND user_status = 0"; } return $wpdb->get_var($query); } To get the number of users registered today, call the function as ...


2

Your answer is on the codex page link in your question. // Get the member type of user 5412. $member_type = bp_get_member_type( 5412 ); So you could do something like this: $member_type = bp_get_member_type( get_current_user_id() ); if ( $member_type == 'dog' ) echo 'Bark';


2

This is a perfect use for the map_meta_cap filter. function my_map_meta_cap( $caps, $cap, $user_id, $args ) { if( 'delete_user' !== $cap ) { return $caps; } if( isset( $args[0] ) && 1 === $args[0] ) { $caps[] = 'cant_do_this'; } return $caps; } add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 ); This code requires that anyone ...


2

function is_user_a_member_of_this_group($user_id, $group_id) //return: bool return groups_is_user_member( $user_id, $group_id ); }


1

Although this is not a WP question, it could be done with some PHP/MySQL code. Just the psuedocode: generate a GUID value on each main page visit check if the GUID is already in the GUID database if not, store the GUID in the GUID database if GUID exists in the database, redirect to another page ("you were already here, only one per customer" message) This ...


1

Fiddling with user roles would probably be the most robust solution, however a quick and dirty approach would be to set post meta-data to mark posts that should be hidden, then add a meta-query to post queries by using a pre_get_posts hook in order to restrict results to non-hidden posts for non-logged-in users. The following will limit all posts queried ...


1

You can use get_current_user_id() - if a user is not logged in, the value will be 0: <a href="http://example.com/uid=<?php echo get_current_user_id() ?>">...</a>


1

Maybe the name of your CPT needs to be changed blogpost You could also add taxonomy type support add_action( 'init', 'add_type_taxonomy' ); function add_type_taxonomy() { register_taxonomy( 'cpt-type', 'cpt', array( 'labels' => array( 'name' => _x( 'Types', 'taxonomy general name', 'theme' ), '...


1

I would say plugins are very easy way to handle membership until unless you want it for a small scale like for few pages/posts etc. In that case you can register the level of users as per your requirements, assign capabilities and then on each page/post you can check if ( current_user_can() ) This can be a solution to manage to a small scale of things. A ...


1

the Short and sweet way would be to store the post id that they are allowed to edit in custom user meta. Then us wp_update_post and check if the id is in the user meta if so update if not don't.


1

I don't think what you want is URL rewriting. If I understand correctly, what you want is to restrict access to certain pages, posts, categories, etc., based on the current user's role or capabilities: "If logged in, do something. If not, do something else (like prompt to login or register)." Modifying the output/behavior of a single page is not all ...


Only top voted, non community-wiki answers of a minimum length are eligible