hooks - Lock user information once fields have been filled in

admin2025-01-07  3

Much like the username is locked down and cannot be changed once it has been registered, I would like to lock down additional fields I have created with Advanced Custom Fields like the person's cellphone number which is vital for us to have because it is linked to a security gate entrance and should not be changed

What I need to be able to have happen is that once someone completes a field and submits their new information, that field needs to be locked down when the page reloads and only an administrator can change it.

I know this can be done with javascript but I want to be sure that someone who knows how to use the Developer Toolbar is not able to change the field attribute and submit or delete content. Or if someone just happens to have JS switched off, they would be able to change this.

Is there a WordPress hook that exists to do something like this please? Here's what I have found, none of which supports my solution.

  1. .6 (to see if a hook like this exists)

EDIT:

I am already making use of the jQuery to check the fields that need to stay locked and disabling them but what I prefer to know is if there are any hooks one could use to do this in WP due to the fact that someone might be know how to bypass this with enough knowledge of Dev Toolbar? I have also done a ton of searches and nothing as specific as what I am trying to do here.

Many thanks

Much like the username is locked down and cannot be changed once it has been registered, I would like to lock down additional fields I have created with Advanced Custom Fields like the person's cellphone number which is vital for us to have because it is linked to a security gate entrance and should not be changed

What I need to be able to have happen is that once someone completes a field and submits their new information, that field needs to be locked down when the page reloads and only an administrator can change it.

I know this can be done with javascript but I want to be sure that someone who knows how to use the Developer Toolbar is not able to change the field attribute and submit or delete content. Or if someone just happens to have JS switched off, they would be able to change this.

Is there a WordPress hook that exists to do something like this please? Here's what I have found, none of which supports my solution.

  1. http://wordpress.org/support/topic/how-to-disable-profile-fields
  2. http://adambrown.info/p/wp_hooks/version/3.6 (to see if a hook like this exists)

EDIT:

I am already making use of the jQuery to check the fields that need to stay locked and disabling them but what I prefer to know is if there are any hooks one could use to do this in WP due to the fact that someone might be know how to bypass this with enough knowledge of Dev Toolbar? I have also done a ton of searches and nothing as specific as what I am trying to do here.

Many thanks

Share Improve this question edited Nov 7, 2013 at 10:37 SixfootJames asked Nov 7, 2013 at 6:00 SixfootJamesSixfootJames 4573 gold badges11 silver badges23 bronze badges 2
  • This looks like a plugin specific question so you better ask the author. – Mark Kaplun Commented Nov 7, 2013 at 8:43
  • I've already checked the plugin's site as well as asked the question there but had no responses yet. – SixfootJames Commented Nov 7, 2013 at 13:12
Add a comment  | 

1 Answer 1

Reset to default 0

I think this can handle, what you want:

Here is the filter documentation http://www.advancedcustomfields.com/resources/filters/acf_update_value/

You can choose whatever filter option you want, but if you use onw of the first two

add_filter('acf/update_value', 'mr_acf_prevent_update', 10, 3);
add_filter('acf/update_value/type=text', 'mr_acf_prevent_update', 10, 3);

You'll have to write more conditionals on the callback function.

If you use one of these two, you don't need

// example with the field name
add_filter('acf/update_value/name=cell-phone', 'mr_acf_prevent_update', 10, 3);
// example with the field key
add_filter('acf/update_value/key=field_527bb4af7edde', 'my_acf_load_field', 10, 3);

and the callback that does the job

function mr_acf_prevent_update( $value, $post_id, $field ) {

    if ( current_user_can( 'manage_options' ) || get_field( $field['name'], $post_id ) == ''  ) {

        return $value;

    } else {
        return get_field( $field['name'], $post_id );
    }

}

It can be improved, it's ugly, but it works!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736263731a914.html

最新回复(0)