• Resolved supernova42

    (@supernova42)


    Hi Roland

    I’ve contacted you a few times about creating a new record within PDB and the fields being empty. I’m using the following routine

    $current_user = wp_get_current_user();
    $wp_username = $current_user->user_login;
    $data=array(‘username’ => $wp_username);
    Participants_Db::write_participant($data);

    The above routine created a record with PDB, but I just could not understand why sometimes the fields were empty and other times they were full.

    The penny has finally dropped…

    The routine only works correctly if I’m logged in as an administrator. If I log in as a Subscriber, Contributor or Author and run the routine, it will create the record but the fields are empty.

    I’ve been through the various access levels within WordPress and the only other user level that allows my routine to work correctly is Editor.

    So the question is, is there some additional code or command I need to add in order to allow Subscribers to run the routine correctly and fill the fields as required. Obviously I don’t want to give them Editor level.

    Many Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author xnau webdesign

    (@xnau)

    What action or filter are you calling your code on? Where is it located?

    Thread Starter supernova42

    (@supernova42)

    This is the code I used to create the initial record. The routine creates a record but the fields are blank if I run it in Subscriber level. In Administration level it works fine.

    $current_user=wp_get_current_user();
    $wp_username=$current_user->user_login;
    $user_id=Participants_Db::get_record_id_by_term(‘username’,$wp_username);
    if(empty($user_id)) {
    $data=array(‘username’ => $wp_username);
    Participants_Db::write_participant($data);
    }

    Plugin Author xnau webdesign

    (@xnau)

    Where are you putting this code?

    Thread Starter supernova42

    (@supernova42)

    I’m using a Plugin called ‘Woody ad snippets’, which allows me to add php and call it via a shortcode from one of my pages.

    Plugin Author xnau webdesign

    (@xnau)

    There isn’t any reason the subscriber’s user_login value wouldn’t be available as long as they are logged in. I’ve tested this with various user roles, including subscriber, and it works, so it’s not a problem in the plugin.

    Thread Starter supernova42

    (@supernova42)

    Enabling the access of ‘Edit Other Posts’ for Subscribers resolves this problem. However, this might not be the best course of action.

    At the moment the php function is accessed via a shortcode. I will contact the Plugin Developer and put the problem to him.

    I will also include my php routine within the actual WordPress page and use the [insert_php] [\insert_php] function. I know that this is not advisable but I will give it a go anyway.

    Finally, I will include my php routine within a separate home-developed plug-in and see what effect that has.

    I will then let you know the result Roland should anyone else have a similar problem.

    Many thanks for an incredibaly addictive plug-in.

    Thread Starter supernova42

    (@supernova42)

    Well I tried all those methods and none of them worked. Although the record was created, the fields were blank.

    However, when I enabled the access to ‘Edit Other Posts’ for Subscribers, all the methods worked. At least I can now get it working, but it seems odd that I have to change the access level for Subscribers.

    What are your thoughts please?

    Plugin Author xnau webdesign

    (@xnau)

    I don’t know what’s going on there. In my tests, it’s not necessary to change the capabilities, so something in your setup is changing the way users work.

    Thread Starter supernova42

    (@supernova42)

    I will continue digging

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Problems with WordPress user levels’ is closed to new replies.