Skip to:
Content
Pages
Categories
Search
Top
Bottom

Possible bug with plugins.php and saving user meta


  • modemlooper
    Moderator

    @modemlooper

    I’m creating a simple profile privacy plugin and when you save the settings on form submission the page refreshes but its not pulling in the new settings you have to refresh page twice. Could this be a problem using plugins.php for the output of the form?

    dev.buddiphone DOTcom

    login test test

    go to settings/privacy and check and save you will see it doesn’t change but when refreshing page the settings are corrected

Viewing 25 replies - 1 through 25 (of 30 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    Yeah, I don’t even need to look, and I already know what’s happening.

    The problem is that you’re catching the form submit too late – the page has already started loading, and your settings have already been cached by WP. You can work around it by doing a bp_core_redirect() after you have run your save routine – that is, save the submitted settings, and instead of letting the page load, bp_core_redirect() back to your settings page.


    modemlooper
    Moderator

    @modemlooper

    It’s weird, I have something similar for a twitter plugin but it’s using a template file instead of plugins.php and this doesn’t happen.


    Boone Gorges
    Keymaster

    @boonebgorges

    Hm. I’d have to see the code to see why it’s causing a problem. I don’t see why using plugins.php would make a difference, unless you’re catching the $_POST submit inside of the bp_template_content function.


    modemlooper
    Moderator

    @modemlooper

    I’m going re do same code using a template file and see if problem solves but it would be better to use plugins.php

    code: http://pastebin.com/fxAt7gNq


    Boone Gorges
    Keymaster

    @boonebgorges

    No, don’t use a template file. plugins.php is not the issue.

    Move your `if ( isset( $_POST ))` stuff up into `bp_privacy_screen_settings_menu()`. Then change it to
    `if ( isset( $_POST ) {
    if (isset($_POST)) {
    update_user_meta($bp->loggedin_user->id, ‘bp-profile-privacy’, ‘1’);
    } else {
    update_user_meta($bp->loggedin_user->id, ‘bp-profile-privacy’, ‘0’);
    }

    bp_core_add_message( ‘Settings updated!’ );
    bp_core_redirect( bp_displayed_user_domain() . $bp->settings->slug . ‘/privacy’ );
    }`


    modemlooper
    Moderator

    @modemlooper

    Ok, working :) the arrangement of code was key. I had tried your suggestion before and did not work because I had the isset checks after the bp_core_load_template.


    dude
    Member

    @pinhit

    Hi chaps, can this plugin work out of the box yet, this code edit to get it to work is giving me grief :(

    should I de-activate it and wait for an update?


    modemlooper
    Moderator

    @modemlooper

    It works you have to edit code no way around that


    dude
    Member

    @pinhit

    The code to edit the default profile.php is in the plugin right?

    so If I’m having trouble copying the plugins profile.php to bp-defaults members/single/
    I basically copy the plugins code and paste it into the existing profile.php file then?
    I tried doing this and it overlapped the existing code so didn’t wanna screw things up
    Am I doing something wrong?


    modemlooper
    Moderator

    @modemlooper

    I just updated plugin and the code edit required has changed. you need to edit home.php instead of profile.php.

    cpanel blows for editing files you need to use an FTP program.


    dude
    Member

    @pinhit

    oh right, I already have a home.php in my child theme!

    it’s currently using an edit to restrict non logged in members from viewing profiles from the outside..will this clash with the updated plugin at all..?


    modemlooper
    Moderator

    @modemlooper

    It could, my plugin allows uses to decide if profiles are open


    dude
    Member

    @pinhit

    I got it to work but when logged in as admin it’s okay as in viewing a non-friend member

    However, if I log in as a member, I cannot view the activity, profile, friends, groups etc of another members profile even when we are friends..?

    strange – I tried deleting then re-installing but still the same problem occurs.

    If it’s any consolation I have a few ‘walled garden style’ code edits on members profiles, groups, forum directories so maybe theres a clash perhaps..?


    dude
    Member

    @pinhit

    ** update **

    tried deleting the walled garden edit (for profile viewing) and running the plugin – no change I’m afraid :(

    Bumping this sorry but this Privacy plugin is way up there on the priority plugin must-haves
    and my site members profiles are open and vulnerable without this functioning

    I refer to the earlier post:

    ” I got it to work but when logged in as admin it’s okay as in viewing a non-friend member

    However, if I log in as a member, I cannot view the activity, profile, friends, groups etc of another members profile even when we are friends..?

    strange – I tried deleting then re-installing but still the same problem occurs.

    If it’s any consolation I have a few ‘walled garden style’ code edits on members profiles, groups, forum directories so maybe theres a clash perhaps..?”.

    Thanks in advance


    modemlooper
    Moderator

    @modemlooper

    No way to tell since you edited default pages. Try reverting members/single files to default.

    okay reverted back to the default and still the same issue

    If I sign in as Admin and view a non-friend profile that has checked the privacy settings I get the message ‘you must be friends with this user to view their profile’ all is good, but..

    If I sign in as a member and go to a friends profile – again that has their privacy settings checked I cannot see any of their profile fields – plus there is nothing on display in terms of the above notice – you must be friends blah blah

    I got rid of ALL walled-garden edits and still the issue persists dude :(

    The trouble is in total I’m running 10 plugins

    I’ve stripped my plugins down to the bone and even sacrificed a couple that I ‘want’ more than ‘need’ if you know what I mean, so can’t afford to lose anymore or major functions on the site will be sorely missed.

    Is it at all possible that this issue with the privacy plugin is ringing any other ‘alarm bells’ apart from plugin conflict..?


    modemlooper
    Moderator

    @modemlooper

    Is profile.php default? I had moved code edits to home.php

    yes it is

    I didn’t go for the first update with the profile.php

    I waited for the most recent home.php update

    I over-wrote the home.php with the plugins in both Bp-default and my child theme.

    Might be worth noting too that when I tried over-writing my child-theme’s home.php the settings privacy component didn’t show on the profiles – so tried bp-default’s and the settings showed..strange ?

    I’m a pain in the ass I know but I appreciate your work so far man, just wish this would work then I can probably put editing to bed for a while as ALL my main tweaks are 99% done !

    The minor alterations I can live with for a while lol


    modemlooper
    Moderator

    @modemlooper

    It could be a child theme problem, try deleting home.php in your child theme and just edit the one in the BuddyPress plugin folder

    I deleted the child theme home.php, still the same problem..should I try deleting and re-installing the plugin perhaps..?

    should I keep the home.php in the plugin itself intact ?

    or should I delete after copying it’s contents into bp-default home.php ?


    modemlooper
    Moderator

    @modemlooper

    Those files in the privacy plugin folder are not referenced

    okay so not a problem then!

    I deleted the child theme home.php as suggested, but still the same problem..should I try deleting and re-installing the plugin perhaps..?


    modemlooper
    Moderator

    @modemlooper

    You can, like is said before, once you start changing things from default it could be any issue that could make plugins non functional. I have the plugin installed on a default bp install dev.buddiphone.com and it works perfect.

Viewing 25 replies - 1 through 25 (of 30 total)
  • The topic ‘Possible bug with plugins.php and saving user meta’ is closed to new replies.
Skip to toolbar